How does Cassandra guarantee eventual consistency when concurrent writes happen?
For example, Client A writes to tableA.rowA.colA, while at the same time Client B writes to tableA.rowA.colA.
The coordinator nodes distribute the request to the replica nodes say NodeA NodeB and NodeC.
On NodeA, ClientA request arrives first. On NodeB, ClientB request arrives first. Then, will it be forever inconsistent?
Cassandra follows a "Last Write Wins" policy. The timestamp used can be set manually but by default is set client side by the requester see Datastax Java Driver docs. The order in which writes arrive is irrelevant. If write A has an earlier timestamp than write B then it will always be overwritten by write B. The only ambiguous case is when the timestamps match exactly. In that case the greater value wins.
The eventually consistent portion of this is:
Most use-cases involve not storing state in Cassandra so these sorts of issues do not arise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With