question

muthuselvam.dwh_190721 avatar image
muthuselvam.dwh_190721 asked Erick Ramirez answered

Why are results inconsistent when reading with consistency ALL compared to ONE?

Hi,

I'm trying to understand the usage of LOCAL_ONE on a read scenario. Will the LOCAL_ONE guarantee a read on a replica node always or it can be any node on the cluster. The documentation says it's the closest replica.

The issue I'm seeing is when I try to run a query with CL as ALL it gives me 150 records and if I try to run the same query with CL as ONE it is returning only 120 records.

At the Opscenter level we are running repairs so the cluster is up to date.

Appreciate your help!

cassandraconsistency
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

For consistency level LOCAL_ONE, the coordinator will pick one replica in the local data centre to send the read request. In the context of servicing reads, "closest" means the request is sent to a replica local to the coordinator as opposed to a replica in a remote DC.

I note that you explicitly said that repairs are up to date but the symptom you described says otherwise.

When you query with a consistency level of ALL, all the replicas in all the data centres will be queried and the data from all of them get merged which means that even if a replica has data missing it won't matter. When the consistency is just ONE, only one replica's data is returned regardless of whether it's out-of-sync or not.

You can verify this behaviour by switching TRACING ON in cqlsh. You will see that when you query with consistency ALL, any discrepancy (shows up as digest mismatch in the trace output) gets fixed by a read repair.

You can read more about this behaviour in Repair in the Cassandra read path. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.