Cassandra Python driver ReadTimeout

1k Views Asked by At

I'm trying to run a cqlsh query using the official python driver:

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

and i'm getting the following error:

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

i tried to increase readtimeout

try #1:

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

try #2:

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

both ways gave me the same readtime error how to increase the readtimeout correctly?

Version Information:

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

There are 1 best solutions below

0
On BEST ANSWER

In cassandra count(*) is a really expensive operation which will need to read all data on all nodes. Given that it is easily possible that count(*) works for a small amount of data but not when there may rows.

There is also a blog post from DataStax about counting: https://www.datastax.com/dev/blog/counting-keys-in-cassandra