How Cassandra handles concurrent updates?
Asked Answered
P

2

12

How does Cassandra handle concurrent updates to the same key by multiple users? Does Cassandra follow the "Isolation" property from ACID?

Paddy answered 16/11, 2015 at 9:38 Comment(0)
C
6

While not truly ACID compliant, Cassandra enforces row-level isolation:

For example, if one user was writing a row with two thousand columns, another user could potentially read that same row and see some of the columns, but not all of them if the write was still in progress.

Full row-level isolation is in place, which means that writes to a row are isolated to the client performing the write and are not visible to any other user until they are complete.

As for competing writes handled by different coordinator nodes, each column value contains a write-time value indicating when it was written. This ensures that the most-recent write to a column occupies the cell. In other words "last write wins."

Cinda answered 16/11, 2015 at 13:29 Comment(2)
what will happen if two concurrent updates are taking place on the same row inside a partition and the updates are read before write kind of updates? Does the Cassandra's row level isolation ensures that the updates are correct from these two request? If yes could you pls mention how does Cassandra accomplishes this?Lorimer
@YugSingh First, read-before-write operations are a known Cassandra anti-pattern. Reason being that the values you read could change before the write executes. As rows are isolated to the client only, no locking or verification of "correctness" of the updates occurs. Writes by a client app updating multiple columns on a row will not be visible to anyone else until all of the updates are complete. If two clients were performing multiple column writes on the same row, the latest write timestamp (per column) would determine the prevailing values.Cinda
A
2

Cassandra provides atomicity and isolation guarantees for row-level updates. You can read more about it in the datastax blog article.

Arsenopyrite answered 16/11, 2015 at 13:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.