Python cql driver - cassandra.ReadTimeout - "Operation timed out - only 1 response received."

I am using Cassandra 2.0 with python CQL.

I created a column family as follows:

CREATE KEYSPACE IF NOT EXISTS Identification WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'DC1' : 1 }; USE Identification; CREATE TABLE IF NOT EXISTS entitylookup ( name varchar, value varchar, entity_id uuid, PRIMARY KEY ((name, value), entity_id)) WITH caching=all ; 

Then I will try to count the number of records in this CF as follows:

 #!/usr/bin/env python import argparse import sys import traceback from cassandra import ConsistencyLevel from cassandra.cluster import Cluster from cassandra.query import SimpleStatement def count(host, cf): keyspace = "identification" cluster = Cluster([host], port=9042, control_connection_timeout=600000000) session = cluster.connect(keyspace) session.default_timeout=600000000 st = SimpleStatement("SELECT count(*) FROM %s" % cf, consistency_level=ConsistencyLevel.ALL) for row in session.execute(st, timeout=600000000): print "count for cf %s = %s " % (cf, str(row)) dump_pool.close() dump_pool.join() if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-cf", "--column-family", default="entitylookup", help="Column Family to query") parser.add_argument("-H", "--host", default="localhost", help="Cassandra host") args = parser.parse_args() count(args.host, args.column_family) print "fim" 

The account is not useful to me, it is just a test with an operation that takes a lot of time.

Although I defined the timeout as 600000000 seconds, after less than 30 seconds I get the following error:

 ./count_entity_lookup.py -H localhost -cf entitylookup Traceback (most recent call last): File "./count_entity_lookup.py", line 27, in <module> count(args.host, args.column_family) File "./count_entity_lookup.py", line 16, in count for row in session.execute(st, timeout=None): File "/home/mvalle/pyenv0/local/lib/python2.7/site-packages/cassandra/cluster.py", line 1026, in execute result = future.result(timeout) File "/home/mvalle/pyenv0/local/lib/python2.7/site-packages/cassandra/cluster.py", line 2300, in result raise self._final_exception cassandra.ReadTimeout: code=1200 [Timeout during read request] message="Operation timed out - received only 1 responses." info={'received_responses': 1, 'data_retrieved': True, 'required_responses': 2, 'consistency': 5} 

It seems that the answer was found only in the replica, but it really does not make sense to me. Should Cassandra be able to ask him?

The figure below shows that the number of requests to the cluster is really low, and latency is low. I am not sure why this is happening.

enter image description here

+7
python cql3
source share
1 answer

From the answer:

 received_responses': 1, 'data_retrieved': True, 'required_responses': 2 

Data is available on only one node, while a query requires consistency == all. Cassandra could not fulfill this request and did not recover.

You can change the record consistency to ALL if you want all nodes to have data.

This ensures that all read requests can be satisfied without agreeing == ALL, as this will be satisfied by the write request itself, although writes can fail if node is disabled.

See the documentation for an explanation of what level of consistency means.

LOCAL_QUORUM is what will be used to ensure that most nodes have access to the replication rate within DC.

+1
source share

All Articles