kha
kha

Reputation: 19993

Is it possible to have dirty reads with CL Quorum?

Based on

http://docs.datastax.com/en/cassandra/2.0/cassandra/dml/dml_config_consistency_c.html

Write Consistency

The consistency level determines the number of replicas on which the write must succeed before returning an acknowledgment to the client application

Read Consistency:

The consistency level specifies how many replicas must respond to a read request before returning data to the client application.

This means, if I specify CL as Quorum for both read and writes, within the same client application (and presumably the same thread), my consequent read of the data (with CL = Quorum) after a write (again, with CL = Quorum) ensures I get the latest data.

What I am not very clear about however is: does this apply across different processes and different threads within the same application as well?

Is it possible to specify CL = Quorum and yet have missed updates (old data) or dirty reads?

Update:

To clarify, I'm not talking about AFTER the CL QUORUM has finished. The question is more along these lines:

If in the middle of the write (@ QUORUM) another process connecting to the same cluster attempts to read the same partition with CL = QUORUM, would it be possible to read old data?

Imagine the write hasn't yet finished writing to all the replicas so the CL hasn't yet been satisfied and a read occurs. Could it be possible that the write has only been written to one node (and in the process of being replicated) and therefore, when the read (with CL = QUORUM) comes in, it reads the older data? Do the nodes somehow know they should "wait" until the writes have finished

Many thanks,

Upvotes: 2

Views: 439

Answers (2)

sam
sam

Reputation: 3511

There is an official formula to know if you will achieve immediate consistency ( = no stalled data) If NUM_READ + NUM_WRITE > Replication Factor then Immediate Consistency

So if RF is 3 , quorum = 2 so if both read and write = QUORUM , then 2 + 2 > 3 = immediate consistency

But if you had read = QUORUM and write = ONE then 2 + 1 = 3 , you only get eventual consistency

Upvotes: 2

Chris Lohfink
Chris Lohfink

Reputation: 16400

As long as both reads and writes are done at QUORUM it will be consistent. Since more than half has seen the write and more than half are returning the read there is guaranteed to be some overlap.

Upvotes: 3

Related Questions