问题
I would like to know which write wins in case of two updates with the same client timestamp.
Initial data: KeyA: { col1:"val AA", col2:"val BB", col3:"val CC"}
Client 1 sends update: KeyA: { col1:"val C1", col2:"val B1"}
Client 2 sends update: KeyA: { col1:"val C2", col2:"val B2"}
Both updates have the same timestamp.
What result will be returned by row query on KeyA ?
{ col1:"val C1", col2:"val B1", col3:"val CC"}- Clint 1 wins{ col1:"val C2", col2:"val B2", col3:"val CC"}- Client 2 wins{ col1:"val C2", col2:"val B1", col3:"val CC"}- mixed update
I expect, that result is unpredictable - since both updates have the same timestamp.
Is mixed scenario also possible?
回答1:
Timestamps are a property of each column not the entire insert itself. Multiple columns with the same exact timestamp are resolved by comparing the actual column value itself. This is done by comparing the values lexically by bytes, so that the value returned is deterministic.
So in your example, if every column inserted by both clients had the same exact timestamp, you could see a mixed update depending on how the actual column values compare.
回答2:
Here is a link to a post I wrote a while ago about Cassandra Timestamps and conflicts.
来源:https://stackoverflow.com/questions/9602413/cassandra-conflict-resolution-for-mixed-column-updates-with-identical-timestam