简体   繁体   English

我应该为“ com.datastax.driver.core.exceptions.ReadTimeoutException”做什么?

[英]what should I do for “com.datastax.driver.core.exceptions.ReadTimeoutException”?

I put almost 190 million records in Cassandra(2.1.11) cluster with 3 nodes, and the replication factor is 1 , then I write client application to count the all records using datastax's Java Driver , the snippet code as follows: 我在具有3个节点的Cassandra(2.1.11)集群中放置了将近190 million records ,并且复制因子为1 ,然后我编写了客户端应用程序以使用datastax的Java Driver对所有记录进行计数,代码段如下:

Statement stmt = new SimpleStatement("select * from test" );

System.out.println("starting to read records ");
stmt.setFetchSize(10000);
ResultSet rs = session.execute(stmt);

//System.out.println("rs.size " + rs.all().size());
long cntRecords = 0;

for(Row row : rs){
    cntRecords++;

    if(cntRecords % 10000000 == 0){
        System.out.println("the " + cntRecords/10000000 + " X 10 millions of records");
    }
}

After the above variable cntRecords is more than 30 millions, I always get the exception: 在上面的变量cntRecords超过3000万之后,我总是得到异常:

Exception in thread "main" com.datastax.driver.core.exceptions.ReadTimeoutException: 
Cassandra timeout during read query at consistency ONE (1 responses were required but only 
0 replica responded)

I got several results in google and changed the settings about heap and GC, the following is my relative settings: 我在google中得到了几个结果,并更改了关于堆和GC的设置,以下是我的相对设置:

-XX:InitialHeapSize=17179869184 
-XX:MaxHeapSize=17179869184 
-XX:MaxNewSize=12884901888 
-XX:MaxTenuringThreshold=1 
-XX:NewSize=12884901888 
-XX:+UseCMSInitiatingOccupancyOnly 
-XX:+UseCompressedOops 
-XX:+UseConcMarkSweepGC 
-XX:+UseCondCardMark 
-XX:+UseGCLogFileRotation 
-XX:+UseParNewGC 
-XX:+UseTLAB 
-XX:+UseThreadPriorities
-XX:+CMSClassUnloadingEnabled 

and I used GCViewer to analysis the gc log file and the througputs are 99.95%, 98.15% and 95.75%. 并且我使用GCViewer分析了gc日志文件,吞吐量分别为99.95%,98.15%和95.75%。

UPDATED BEGIN: And I used jstat to monitor one of the three nodes and found that when the S1 's value changed into 100.00 I will get the above error quickly: 更新开始:我使用jstat监视三个节点之一,发现当S1的值更改为100.00我将迅速得到上述错误:

/usr/java/jdk1.7.0_80/bin/jstat -gcutil 8862 1000 
S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
0.00 100.00  28.57  36.29  74.66     55   14.612     2    0.164   14.776

And once S1 changed into 100.00 , S1 no longer will decrease, I don't know this is relative to the error? 并且一旦S1更改为100.00S1将不再减少,我不知道这是与错误有关的吗? Or what property in cassandra.yaml or cassandra-env.sh I should set for this? 还是应该为此设置cassandra.yamlcassandra-env.sh什么属性?

What should I do for finishing the task to count the all records? 完成该任务以计算所有记录该怎么办? Thanks in advance! 提前致谢!

ATTACH: the following is other options: 附加:以下是其他选项:

-XX:+CMSEdenChunksRecordAlways 
-XX:CMSInitiatingOccupancyFraction=75 
-XX:+CMSParallelInitialMarkEnabled 
-XX:+CMSParallelRemarkEnabled 
-XX:CMSWaitDuration=10000 
-XX:CompileCommandFile=bin/../conf/hotspot_compiler 
-XX:GCLogFileSize=94371840 
-XX:+HeapDumpOnOutOfMemoryError 
-XX:NumberOfGCLogFiles=90 
-XX:OldPLABSize=16 
-XX:PrintFLSStatistics=1 
-XX:+PrintGC 
-XX:+PrintGCApplicationStoppedTime 
-XX:+PrintGCDateStamps 
-XX:+PrintGCDetails 
-XX:+PrintGCTimeStamps 
-XX:+PrintHeapAtGC 
-XX:+PrintPromotionFailure 
-XX:+PrintTenuringDistribution 
-XX:StringTableSize=1000003 
-XX:SurvivorRatio=8 
-XX:ThreadPriorityPolicy=42 
-XX:ThreadStackSize=256 

Examine why you need to know the number of rows. 检查为什么您需要知道行数。 Does your application really need to know this? 您的应用程序真的需要知道这一点吗? If it can survive with "just" a good approximation, then create a counter and increment it as you load your data. 如果它可以“近似”良好的近似值存活,则创建一个计数器,并在加载数据时对其进行递增。

http://docs.datastax.com/en/cql/3.1/cql/cql_using/use_counter_t.html http://docs.datastax.com/en/cql/3.1/cql/cql_using/use_counter_t.html

Things you can try: 您可以尝试的事情:

  • Select a single column instead of * . 选择单列而不是* This might reduce by GC pressure and network consumption. 这可能会降低GC压力和网络消耗。 Preferably pick a column that has a small number of bytes and is part of the primary key: select column1 from test 最好选择一个字节少且属于主键的列: select column1 from test
  • Add a short pause after every 1M records. 每100万条记录后添加一个短暂的暂停。 Have your loop pause for 500ms or so every 1M records. 每1M记录使循环暂停500ms左右。 This may give the nodes a quick breather to take care of things like GC 这可以使节点有更快的呼吸来处理诸如GC之类的事情
  • Edit cassandra.yaml on your nodes and increase range_request_timeout_in_ms and read_request_timeout_in_ms 在您的节点上编辑cassandra.yaml并增加range_request_timeout_in_msread_request_timeout_in_ms
  • Figure out the token ranges assigned to each node and issue a separate query for each token range. 找出分配给每个节点的令牌范围,并对每个令牌范围发出单独的查询。 Add the counts from each query. 添加每个查询的计数。 This takes advantage of the token-aware driver to issue each "token range" query directly to the node that can answer it. 这利用了令牌感知驱动程序的优势,将每个“令牌范围”查询直接发布到可以回答该查询的节点。 See this blog article for a full description with sample code. 有关示例代码的完整描述,请参见此博客文章

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.datastax.driver.core.exceptions.InvalidQueryException:未配置的表用户” - com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table user" 使用Datastax Java驱动程序的com.datastax.driver.core.exceptions.InvalidQueryException - com.datastax.driver.core.exceptions.InvalidQueryException using Datastax Java driver 线程“ main”中的异常com.datastax.driver.core.exceptions.InvalidQueryException:PRIMARY KEY中引用的未知定义 - Exception in thread “main” com.datastax.driver.core.exceptions.InvalidQueryException: Unknown definition referenced in PRIMARY KEY 卡桑德拉数据库。 com.datastax.driver.core.exceptions.InvalidQueryException:未配置的表人 - Cassandra DB. com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table person 引起:com.datastax.driver.core.exceptions.InvalidQueryException:日期 (25) 的预期长度为 8 或 0 字节 - Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Expected 8 or 0 byte long for date (25) Cassandra-com.datastax.driver.core.exceptions.DriverException:尝试获取可用连接时超时 - Cassandra - com.datastax.driver.core.exceptions.DriverException: Timeout while trying to acquire available connection 引起原因:com.datastax.driver.core.exceptions.SyntaxError:行0:-1输入不匹配&#39; <EOF> &#39;期待&#39;)&#39; - Caused by: com.datastax.driver.core.exceptions.SyntaxError: line 0:-1 mismatched input '<EOF>' expecting ')' com.datastax.driver.core.exceptions.InvalidQueryException:未配置的表schema_keyspaces - com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table schema_keyspaces com.datastax.driver.core.exceptions.InvalidQueryException: 未配置表 peers_v2 - com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table peers_v2 删除表不起作用-com.datastax.driver.core - drop table not working - com.datastax.driver.core
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM