Cassandra Python驱动程序ReadTimeout

时间:2018-01-05 09:56:06

标签: python cassandra datastax-enterprise datastax-python-driver

我试图使用官方python驱动程序运行cqlsh查询:

>>> session.execute('select count(*) from cassandra_table')

我收到以下错误:

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': 'LOCAL_ONE'}

我试图增加readtimeout

尝试#1:

>>> session.default_timeout = 60.0
>>> session.execute('select count(*) from cassandra_table')

尝试#2:

>>> session.execute('select count(*) from cassandra_table', timeout=60.0)

两种方式都给了我相同的读取时错误 如何正确增加readtimeout?

版本信息:

Cassandra   3.11.0.1900
Spark   2.0.2.6-de611f9
DSE               5.1.5
cassandra-driver 3.12.0

1 个答案:

答案 0 :(得分:0)

在cassandra中count(*)是一项非常昂贵的操作,需要读取所有节点上的所有数据。鉴于count(*)很容易为少量数据工作,但在有可能存在行时则不行。

DataStax还有一篇关于计算的博客文章:https://www.datastax.com/dev/blog/counting-keys-in-cassandra