pythoncassandracqlcql3cassandra-driver

Python cassandra driver Readtimeout


Every time I try to get query using the cassandra python driver, I will receive such an exception:

**File "something.py", line 32, in <module>
    rows = session.execute('some query execution', timeout=None)
  File "C:\Anaconda2\lib\site-packages\cassandra\cluster.py", line 2141, in execute
    return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state).result()
  File "C:\Anaconda2\lib\site-packages\cassandra\cluster.py", line 4033, in result
    raise self._final_exception
cassandra.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'}**

To avoid this exception, I have already tried to set the default timeout to none, like:

cluster.default_timeout = None
session.default_timeout = None
session.execute('some query execution', timeout=None)

However, they never really change the Readtimeout period.

One thing to notice is that this query command doesn't take too long of a time when I execute it in Squrriel, about 1.5 seconds.

Does anyone know how to solve this problem? Thank you!


Solution

  • The key message here is Coordinator node timed out waiting for replica nodes' responses - this means that timeout happens inside Cassandra itself. In your case, request doesn't go directly to the node that owns the data, but to one of the nodes that acts as Coordinator, and this node then re-sends request to the node that owns the data, and doesn't get answer from it during allocated time.

    I don't remember precisely, but Python driver should use so-called TokenAware load balancing policy that will make driver to send requests directly to nodes that own the data - you need to check that you use this policy.

    Also, you need to check logs on the Cassandra nodes to find why they are timeout, and if necessary, tune timeouts on these nodes.