Cassandra timeout

1.1k views Asked by At

Here is my Cassndra table

CREATE TABLE ipaddresss (
    ipAddress text,
    time timestamp,
    clientId inet,
    ..
    ..
    ..
    PRIMARY KEY (ipAddress, time, clientId)
) WITH CLUSTERING ORDER BY (time DESC, clientId ASC)

And I have 6 node Cassandra cluster

And When I am trying to get the below READ query using Java Driver,

select * from ipaddresss where ipAddress = '12.45.67.89' AND time > '2016-11-21' 

I am very frequently getting com.datastax.driver.core.exceptions.ReadTimeoutException: Cassandra timeout during read query at consistency ONE (1 responses were required but only 0 replica responded). I get the answer most of the times, but still have lot of timeout coming even system is not under load.

The Resultset has max 1000 rows, so setting Fetchsize didnt helped

1

There are 1 answers

2
Aaron On

Just curious, but how many CQL rows are stored in each ipAddress partition? The number of columns for each row will also increase the size of the result set. Try your query from cqlsh and see if you still receive timeouts. Otherwise, try limiting your result set by querying a finite time range within that partition.

Example:

select * from ipaddresss where ipAddress = '12.45.67.89' 
  AND time >= '2016-11-21 00:00' and time < '2016-11-21 04:00';

Otherwise, it's possible that Spring Data Cassandra itself might be causing your issue. When paging through large result sets, Spring Data Cassandra does a (very inefficient) SELECT COUNT(*) behind the scenes. If you can make this query work outside of Spring-Data-Cassandra, then that might be your issue. When in doubt you should always use a DataStax-approved driver, which Spring-Data-Cassandra is not.