Varun Gupta
Varun Gupta

Reputation: 1457

replication fails after achieving consistency level

I have replication factor of 3 and consistency level of LOCAL_QUORUM. My cluster size is 5.

With LOCAL_QUORUM, my client write results success after data is written to two nodes. But how does replication to third node happen, like how cassandra selects that third node, and what or when cassandra fails to replicate on third node?

I need to understand more on replication part. Because if one of the two nodes used to write fails then my read will not be able to achieve LOCAL_QUORUM consistency.

Upvotes: 1

Views: 72

Answers (2)

Andy Tolbert
Andy Tolbert

Reputation: 11638

The consistency level is not a reflection of how many replicas are to be written to, but how many replicas are required to acknowledge the write before the coordinating cassandra node can return the response back to the client. The write will be done on all replicas eventually, and even if that fails there are mechanisms like hints, read repair and repairs to get your data into a consistent state.

On read, if you want strong consistency, you should make sure that the summation of your read consistency and write consistency exceed your replication factor.

In your case, with a replication factor of 3, using LOCAL_QUORUM for read and write operations requires at least 2 replicas for reads, and 2 for writes, which is greater than your replication factor (3).

Given this, even if writes fail to the other replicas, but succeeded on two providing you a successful response to the write, as long as you read with a consistency level requiring 2 replicas or greater (i.e. LOCAL_QUORUM) you can be ensured you will get the right data back.

You can read more about this in the datastax docs about consistency:

Reliability of read and write operations depends on the consistency used to verify the operation. Strong consistency can be guaranteed when the following condition is true:

R + W > N

Upvotes: 2

RussS
RussS

Reputation: 16576

When you write with LOCAL_QUORUM you are writing to all nodes BUT you only wait for LOCAL_QUORUM acknowledgements. This means that the write to the third (slow) node may happen after acknowledgement or may be saved as a hint if it was unable to be delivered.

Upvotes: 2

Related Questions