Imagine a E-commerce application:
Let's say I have three Node cluster
N1, N2, N3.
and my consistency level (CL) is weak:
That is
Read CL = N/2+1 = 2 (in this case), Write CL = Any (alteast 1)
I have a product table such as
This is the initial data that is in sync across three Nodes
product_info : { 'computer': 1}
Now Client A reads the info from N1 and Client B reads the info from N2
Client 1 sees 1 computer is available
client 2 sees 1 computer is available
Both of them now go for buying Client A places the order first. so N1, the table will look like the following:
product_info : {'computer':0}
and now client 2 makes the order so at N2, the table will look like the following:
product_info : {'computer':0}
But in reality client 2's order should not have been processed.
client C access through N3. Now a read is done at N1 which returns 0. (since quorum at least 2 nodes should respond) N3 has value of 1 but its time-stamp is outdated. so It will update its value and shows to client that no computers are available. This is good
In this example, both weak and strong consistency level will lead to wrong results, simply because at the time when the first product_info is loaded by client A and B, the data is in sync. How can this be handled in Cassandra?