question

Amit avatar image
Amit asked TaiwanJimmy edited

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
1 comment
10 |1000

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

TaiwanJimmy avatar image TaiwanJimmy commented ·

Hello,

In this case, Cassandra compares the Timestamp of the records which has same details and the one with the latest timestamp is returned. Because, Cassandra uses Timestamp to resolve conflicts between the data which is stored in Memtable or SSTable.

For further Info Visit Download Best Photo editing App, Good Luck!

0 Likes 0 ·

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.