question

Amit avatar image
Amit asked Erick Ramirez answered

How does Cassandra resolve conflicts when reading data?

I am reading about cassandra and its internal working. There is two use cases which I am not able to understand how cassandra resolve these

Context

Suppose cassandra has N1, N2, N3 and they are the replicas. Now

Use case 1

1. Suppose at the same time on the same node say N1 - cassandra gets `insert` and `update` command like this `insert into table X ( "name", "position") values ("amit", "tech arch")` and update is like `update table X set position = "product manager" where name="Amit` .. In this case, how cassandra going to resolve conflict

Usecase 2

Suppose again the insert and updates are happening at the same time - however this time insert is going on one node N1 and update is going on another node say N2. In this case how cassandra resolves the conflict ..

cassandra
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

In all cases, Cassandra returns the latest data in the result set. Another way of saying it is that the data with the newest timestamp wins.

When data is written, it is always stored with the write timestamp. You can choose to use a client timestamp (default) or server-side timestamp. This timestamp is used to determine whether the result returned by replicas is the latest.

For more information, see How read requests are accomplished in Cassandra. 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.