Conflict Resolution Strategies

Conflict Resolution Strategies

Last Write Wins (LWW)

Used by: Cassandra, DynamoDB (default mode)

Compare timestamps. Highest wins. Discard the other.

India currently has:  name = "shi"  (t=110)
Late entry arriving:  name = "hat"  (t=101)

t=110 > t=101  →  keep "shi", discard "hat"

Result: both nodes converge to "shi". "hat" is gone — permanently and silently. This is silent data loss. It is an accepted tradeoff.

Vector Clocks + Conflict Surfacing

Used by: DynamoDB (advanced mode), Riak

Instead of discarding, track which writes knew about which other writes.

Three writes with vector clocks: India at t=100 writes name=sat with vc IN 1, US 0. US at t=101 writes name=hat with vc IN 0, US 1. India at t=110 writes name=shi with vc IN 2, US 0. When hat arrives at India, compare its vector IN 0, US 1 with India’s IN 2, US 0: India is ahead on IN, hat is ahead on US. Neither knows about the other, so they are truly concurrent: a conflict.
Each vector is ahead on one entry, so neither write saw the other LWW would compare t=110 with t=101 and silently drop “hat”; the vector comparison instead proves the two writes are concurrent and keeps both.

The system does not pick a winner. It stores both and returns both:

read("name") → ["shi", "hat"]   ← your application must decide

No data is lost. But your application must handle the conflict — merge them, pick one, or show both to the user.

Synchronous quorum (see Synchronous consensus) sidesteps this entirely: if you chose Option 1, only one write is ever committed at a time — the second is blocked until the first is agreed on. The late-entry scenario in this part cannot occur. The cost, as before, is paying ~200ms per write for cross-region agreement.

The Core Distinction: Log vs. State

Left, the log: what happened, in order. t=100 name=sat, t=101 name=hat, t=110 name=shi; the three are concurrent, since hat saw neither India write. Right, the database state, current values: India has name=shi; US has name=hat, briefly, before it receives shi. The state is derived by applying the log.
The log keeps every write; the state keeps one value per node

The log records events. The database state is derived by applying those events. When a late entry arrives, the log gets a new entry appended at the end — the database does not go back in time. The conflict resolution strategy decides what that new entry does to the current state: overwrite it (LWW) or surface it as a conflict (vector clocks).

What "Eventually Consistent" Actually Means

Convergence timeline under last-write-wins. Phase 1, diverge: India writes name=sat at t=100 and name=shi at t=110; US writes name=hat at t=101. Phase 2, ship: India ships sat, US ships hat, India ships shi. Phase 3, resolve: India receives hat late, already has shi at t=110, and since 110 is greater than 101 discards hat. US ignores sat because 100 is less than 101, then receives shi at t=110 and applies it. Phase 4, converged: both nodes hold name=shi. Until then, readers in India and US can see different values.
Diverge, ship, resolve, converge — and nothing promises when phase 4 arrives Eventual consistency guarantees only the last row: if writes stop, every node ends on the same value. It says nothing about how long phases 2–3 take.

The guarantee is narrow: if all writes stop, all nodes will eventually agree on the same value. It does not guarantee when. It does not prevent stale reads during the convergence window. A user reading from India and a user reading from US can see different values at the same time — this is expected behavior, not a bug.

Where Do You Pay?

ApproachWrite speedConflict riskData loss riskComplexity
Synchronous (Spanner, CockroachDB)Slow (~200ms)NoneNoneLow
Async + LWW (Cassandra, DynamoDB)Fast (local)YesYes (silent)Low
Async + Vector Clocks (Riak)Fast (local)YesNoneHigh (app handles conflicts)

The choice: do you pay at write time (latency) or at conflict time (complexity / data loss)?