cassandradatastax-java-drivercassandra-driver

DSE cassandra driver for java returning only partial results in async mode


I'm getting only partial set of rows when fetching from cassandra using dse cassandra driver 3.1.4 for java. Also This query is working fine with the earlier version of driver we were using. The earlier version was 2.1.9

Table structure is like this

Key     column1 value
CM~020  000001000  20
CM~010  000001000  10

When I query for multiple rows using async call, I get only one row most of the time. Sometimes while debugging I get another row as well.

The behaviour is random but I always get either 2nd row or both. I never get the first row only, so I think this has some role to play here as well.

for (Object partitionKey : partitionKeys) {
        paramArray[0] = partitionKey;
        futures.add(session.executeAsync(boundStatement.bind(paramArray)));
}

Is there a way to make sure I get all the rows every time?


Solution

  • The most obvious thing here is that you have race condition - I see that you're re-using the same array object to specify parameters, and from your source code it looks like that you're using the same BoundStatement instance, so you're overwriting request data...

    I recommend instead modify your code to use preparedStatement.bind(paramArray) instead of boundStatement.bind(paramArray) -> it will create new BoundStatement instance instead.

    P.S. If it did work before, then this was just coincidence...