【发布时间】:2018-06-22 08:11:40
【问题描述】:
我有 4 个节点 dse 5.1.2 Cassandra 集群,平均每个节点有 3 GB 数据。我正在尝试查询该数据。我知道我不应该执行以下查询,因为它对 cassandra 有不良影响。但我观察到的是
select * 有效,但 select count(*) 失败
在同一个表上,协调器超时。当两者在读取时在后台执行相同的操作时,为什么会有所不同。 我的集群已 100% 修复,并且在该表中未找到任何墓碑。我还在 cqlsh 命令中增加了读取请求超时。
我收到以下查询错误
select count(*) from xxx.xxxx;
ReadTimeout: Error from server: code=1200 [Coordinator node timed out waiting for replica nodes' responses] message="Operation timed out - received only 0 responses." info={'received_responses': 0, 'required_responses': 1, 'consistency': 'ONE'}
【问题讨论】:
-
打算以编程方式或一次性获取计数?
-
我有 spark 代码来获取计数。但仍然不明白为什么会在 cqlsh 中发生这种情况。
-
Cassandra 或任何分布式系统都不是为运行需要每个分区中的每一行都响应的查询而设计的。所以 count(*) 工作可能会受到打击。如果您需要计数的近似值,cassandra 使用“nodetool cfstats”命令或通过 JMX 计数器 EstimatedColumnCountHistogram 公开它
标签: cassandra datastax-enterprise datastax-java-driver cassandra-3.0 cqlsh