1

I am facing a puzzling issue where my cassandra reads didn't return a value for key 'K'. I have a key that was inserted into a column family almost 2 weeks back and when I queried for that key using CQLSH consecutively 8 times, 2 times it didn't return a value. 6 times it showed the results correctly. The replication factor for my keyspace is 3.

This key was written with a QUORUM consistency (Java Hector client). I am reading it using CQLSH, which has a default consistency of one. I have not been able to come up with any explanation for this till now. Any thoughts ?

invinc4u
  • 1,125
  • 3
  • 15
  • 26

1 Answers1

2

The reason is that you are not respecting the consistency level disequation:

(WRITE CL + READ CL) > REPLICATION FACTOR

With RF = 3 -> QUORUM = 2

So your disequation say

((WRITE CL) 2 + (READ CL) 1) > 3
2 + 1 > 3 = FALSE

In this post you can find how to achieve consistency. However you might be interested in tuning your read repair chance

Try to set CL quorum in CQLSH using the CONSISTENCY command

cqlsh> CONSISTENCY QUORUM;

And perform the read again

HTH, Carlo

Community
  • 1
  • 1
Carlo Bertuccini
  • 19,615
  • 3
  • 28
  • 39
  • Hey @Carlo thanks for the information. But isn't consistency just for ensuring the freshness of data returned ? Even if I use a read consistency of ONE (I used QUORUM consistency for writes), it would return the data for this specific key from the closest replica that holds this key. I can understand that with weak consistency you might not get the latest value for this key. But how is it possible that I don't get data for this key at all ? I have been trying to reason out under what circumstances cassandra wouldn't return data for an existent key at all, even if it is there ? – invinc4u Oct 13 '14 at 20:49
  • If you have 3 node RF for key K, and you wrote it with CL=Quorum it means only 2 nodes wrote it before returning control to the client. If a read with CL=1 is performed and the first node to answer is the one missing K you won't have any result back -- to verify try to set the CL as I say in my edited answer – Carlo Bertuccini Oct 13 '14 at 20:57