Reputation: 172
Will Cassandra generated time vary depending upon app request generated time?
Scenario
Assume that i have two app nodes which sends write request and delete requests to Cassandra node. The order of execution is
App2 node lags App1 node by a difference of about 500ms. So delete request from app2 side gets a timestamp earlier than the wite request, and it never happens.
Induced a sleep between the two request by 1 sec to solves this, but wanted to understand how Cassandra clock works for writes for each request, when app time is not in sync.
TIA
Upvotes: 0
Views: 284
Reputation: 3444
Some notable things about Cassandra:
So to answer your question directly
Cassandra detects a conflict as (presumably) it's the same record. It therefore applies the client timestamp validation logic to get a winner and app1 write wins and delete is ignored.
When you add a delay of 1 sec, your entries are in correct order and there is no conflict which ensures the writes are deleted correctly.
This old article from DataStax will explain in more details: http://www.datastax.com/dev/blog/why-cassandra-doesnt-need-vector-clocks
The bottom line is that Cassandra CQL relies on client timestamp for such conflict resolutions.
This is a very simplified version of events and does not apply to complex scenarios. Please read the blog for better understanding of conflict resolution w.r.t. clocks in Cassandra.
Upvotes: 1