Does Cassandra discards the failed write record or propagates it during read repair?

Assume I have a 2 node cluster with Replication Factor of 2

  1. A write is initiated with Consistency 2
  2. One node completes the write and another node fails just before completing the write.
  3. Client receives failed response as consistency level cannot be met
  4. Another client reads the same row with consistency 2
  5. One node has latest data (failed record) and other node has old data so read repair is initiated

Q1. During read repair, will Cassandra discard the failed write even though it has the latest timestamp or will it propagate the value written during failed write at step 2 above as it is the value with latest timestamp?

Q2. what is outcome during read repair, if we replace the steps 1 to 3 with a write of consistency 1 and successful write? How read repair differentiates this from the partially failed write?

The text below is from datastax documention

https://docs.datastax.com/en/ddac/doc/datastax_enterprise/dbInternals/dbIntTransactionsDiffer.html

For example, if using a write consistency level of QUORUM with a replication factor of three, the database replicates the write to all nodes in the cluster and waits for acknowledgement from two nodes. If the write fails on one node but succeeds on another node, Cassandra reports a failure to replicate the write on that node, but the replicated write that succeeds on the other node is not automatically rolled back.

Cassandra uses client-side timestamps to determine the most recent update to a column. The latest timestamp always wins when requesting data, so if multiple client sessions update the same columns in a row concurrently, the most recent update is the one seen by readers

Upvotes: 0

Views: 472

Answers (1)

Suhas NM
Suhas NM

Reputation: 1090

"Q1. During read repair, will Cassandra discard the failed write even though it has the latest timestamp or will it propagate the value written during failed write at step 2 above as it is the value with latest timestamp?"

A: Although write has failed since the required number of successful writes to nodes are not met, latest value stored in the node which had a successful write will still be persisted and not rolled back. And when the other nodes are online, a read repair is initiated and nodes will be updated with new data.

"Q2. what is outcome during read repair, if we replace the steps 1 to 3 with a write of consistency 1 and successful write? How read repair differentiates this from the partially failed write?"

A: If we have a write consistency of 1 and if one node is successfully updated with data, write is considered successful. When the other node comes online, read repair is initiated and value is added/updated in the failed node. Read will be successful as long as 2 nodes are alive, if data is not matching, latest data will be received and the other node is updated with the data.

You can take a look at this blog

Upvotes: 3

Related Questions