Linearizability Guarantees by Cassandra
Learn how Cassandra provides linearizability guarantee.
We'll cover the following
Cassandra has another consistency level that provides linearizability guarantees. This level is called SERIAL, and the read/write operations executed in this level are also referred to as lightweight transactions LWTs.
Implementing SERIAL
This level is implemented using a 4-phase protocol based on Paxos, as shown in the following illustration:
Phase one
The first phase of the protocol is called prepare and corresponds to the nodes trying to gather votes before proposing a value which is done in the third phase, called propose.
When run under the SERIAL level, the write operations are conditional using an IF clause, also known as compare-and-set (CAS).
Phase two
The second phase of the protocol is called read and is used to retrieve the data to check whether the condition is satisfied before proceeding with the proposal.
Phase three
The phase three of the protocol is the same as phase one. It satisfies the same need as phase one. It proposes a value to the nodes.
Phase four
The last phase of the protocol is called commit, and it’s used to move the accepted value into Cassandra storage and allow a new consensus round, thus unblocking concurrent LWTs again.
Note: Read and write operations executed under SERIAL are guaranteed to be linearizable.
-
Read operations will commit any accepted proposal that has not been committed yet as part of the read operation.
-
Write operations under SERIAL are required to contain a conditional part.
Get hands-on with 1400+ tech skills courses.