Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

leehuihua avatar image
leehuihua asked ·

Java driver retry policy onReadTimeoutVerdict

Hi All:

This is quoted from the document:retry policy:

"During reads, Cassandra doesn’t request data from every replica to minimize internal network traffic; instead, some replicas are only asked for a checksum of the data. A read timeout may occur even if enough replicas responded to fulfill the consistency level, but only checksum responses were received (the method’s dataPresent parameter allow you to check if you’re in that situation)."

I don't get it. If a read time out occurs, there should not be enough replicas responded to fulfill the consistency level, because for read operations, the coordinator generally only issues read commands to enough replicas to satisfy the consistency level. So if one replica time out ,the consistency level could not be satisfied. Is there anything I miss?

For example,In a single data center cluster with a replication factor of 3, and a read consistency level of QUORUM, only 2 of the 3 replicas will be requested for a read request, one for full data request, the other for digest request? If one of them times out ,the coordinator return read time out exception to the client?

Thanks a lot!

java driver
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

alexandre.dutra avatar image
alexandre.dutra answered ·

You are right that when executing a read operation, the coordinator generally only contacts the exact number of replicas required to fulfill the consistency level.

However, Cassandra has the notion of "read repair". Read repair is one of Cassandra's anti-entropy mechanisms. When read repair is enabled, some read requests can cause the coordinator to contact all replicas, and if there is a data digest mismatch, a background repair command will be sent to the replicas.

With read repair, a read command can timeout because the replica that was asked for the data didn't respond, even if all other replicas responded.

That's why the driver documentation that you quoted warns you that a ReadTimeoutException could happen even if blockFor < received.

1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

thanks! The cases where read requests can cause the coordinator to contact all replicas are decided by the configuration : read_repair_chance ? And this situation does not exist anymore after caasnadra 4.0 according to this doumment: Remove read_repair_chance/dclocal_read_repair_chance


0 Likes 0 ·