Implement Last-Write-Wins conflict selection and show how clock skew, ties, and concurrent whole-object updates can converge deterministically while silently discarding meaningful AtlasMart data.

Last-Write-Wins: Simple Semantics, Clock Dependence, and Silent Data Loss

LWW is a winner-selection rule, not a semantic merge. This lesson separates deterministic convergence from domain correctness and identifies the narrow cases where information loss is explicitly acceptable.

Advanced105–140 minutesLWW/clock-skew labPython 3.13+ · standard libraryVendor-neutral · free/local mandatory pathLast reviewed: August 2026
01

Define Last-Write-Wins as a winner-selection policy rather than a semantic merge.

02

Show how clock skew and disconnected concurrency can make the selected winner differ from real-time or business intent.

03

Distinguish deterministic convergence from correctness of the surviving value.

04

Identify narrow cases where losing intermediate values is acceptable because the data is replaceable or advisory.

1. LWW solves “which value survives,” not “which value is correct”

Last-Write-Wins (LWW) assigns each competing value an order—often a timestamp plus a deterministic tie-breaker—and keeps the greatest one. Replicas can converge because they apply the same comparison rule. That simplicity is attractive: no sibling set, no human review queue, and no application merge code.

But the name can mislead. “Last” usually means greatest according to the chosen metadata, not “the user's physically latest intention” and not “the value that preserves the invariant.” If physical clocks are used, skew can reverse apparent order. If two writes are truly concurrent, there may be no meaningful causal last writer at all.

2. Clock skew turns physical time into a fragile conflict oracle

AtlasMart's east client updates a cart at real time 1000 ms, but its clock is 80 ms fast and attaches timestamp 1080. West updates the same cart at real time 1030 ms, but its clock is 100 ms slow and attaches timestamp 930. An LWW resolver chooses east. The physically later west update disappears.

Write Real time Clock skew Attached timestamp Cart value
east 1000 ms +80 ms 1080 [battery]
west 1030 ms -100 ms 930 [cable]
LWW result — — 1080 wins [battery]; cable lost

Even perfect clocks do not solve semantic concurrency. Two users can intentionally update different aspects during overlapping intervals. A deterministic total order always chooses a winner, but it cannot infer whether both edits should survive.

3. Tie-breaking guarantees convergence, not meaning

If two values carry the same timestamp, a system still needs a deterministic tie-breaker or replicas that receive them in different orders could disagree. A product might compare value bytes, node IDs, or another stable field. That rule is an implementation mechanism, not a domain rule.

Optional implementation cross-check

Apache Cassandra 5.0.9 (Apache License 2.0) is used only as a current example of a timestamp-oriented distributed database where winner selection and repair semantics are implementation-specific. No Cassandra installation, Java runtime, CQL driver, container, or cloud service is required. Do not transfer Cassandra-specific tie-break rules into a vendor-neutral conflict-resolution design.

Cassandra's current documentation explicitly treats equal-timestamp winner details as an implementation detail. That is the right mental separation: product tie-breaking makes replica state deterministic, while application correctness must come from the data model and business invariant.

4. AtlasMart lab: silent data loss under skew

Mandatory lab environment

Python 3.13+ standard library only. The generated lab was verified with Python 3.13.5. No database server, Docker, cloud account, paid feature, credential, firewall change, clock manipulation, process killing, or destructive failure injection is required. All conflicts, partitions, retries, and failures are deterministic in-memory simulations.

The lab compares real time with client-supplied timestamps, demonstrates a deterministic timestamp tie, and contrasts a high-value cart with a replaceable presence field.

python · AtlasMart deterministic simulation
writes = [
    {"replica": "east", "real_ms": 1000, "clock_skew_ms": 80, "ts": 1080,
     "cart": ["battery"]},
    {"replica": "west", "real_ms": 1030, "clock_skew_ms": -100, "ts": 930,
     "cart": ["cable"]},
]
print("CONCURRENT/DISCONNECTED CART WRITES")
for w in writes:
    print(w)

winner = max(writes, key=lambda w: (w["ts"], w["replica"]))
print("\nLWW winner by timestamp:", winner)
print("physically later write lost:", winner["real_ms"] < max(w["real_ms"] for w in writes))
print("business information lost: cable is absent ->", "cable" not in winner["cart"])

print("\nDETERMINISTIC TIE BREAK IS STILL ONLY A WINNER RULE")
tie = [
    {"replica": "A", "ts": 2000, "value": "address=A"},
    {"replica": "B", "ts": 2000, "value": "address=B"},
]
tie_winner = max(tie, key=lambda w: (w["ts"], w["value"]))
print("tie winner:", tie_winner)
print("deterministic convergence: yes; domain correctness: not established")

print("\nA REPLACEABLE FIELD CAN HAVE DIFFERENT RISK")
presence = [
    {"replica": "A", "ts": 3000, "value": "online"},
    {"replica": "B", "ts": 3010, "value": "away"},
]
print("presence LWW:", max(presence, key=lambda w: w["ts"]))
print("acceptable only if product semantics explicitly allow intermediate presence states to disappear")
Expected evidence

The timestamp winner is not the physically later write, and one cart item disappears. A lexical tie-break converges deterministically but does not establish the correct shipping address. A replaceable presence indicator can tolerate LWW only because AtlasMart explicitly declares that intermediate states are not authoritative business facts.

5. Where LWW can be reasonable

LWW is defensible when overwriting older information is already the domain semantics and the value is cheap to reconstruct or low consequence. Examples can include an advisory “last viewed category,” an ephemeral presence indicator, or a cache-like hint where occasional loss is acceptable. Even then, define clock source, skew assumptions, timestamp precision, tie-breaker, replication behavior, and how deletes interact with older values.

LWW is much harder to justify for money, inventory reservations, entitlement grants, legal-state transitions, or collections where concurrent additions should both survive. A cart represented as one LWW register is especially risky: independent item additions collapse into one whole-object winner.

6. Deliberately wrong approach: “hybrid logical clocks make LWW semantically correct”

Hybrid Logical Clocks (HLCs) improve ordering and retain a relation to physical time, but they do not magically merge business meaning. An HLC can produce a stable order between concurrent operations; that still means one operation may be discarded. The question is whether discarding it is acceptable. Ordering technology and conflict semantics are separate design decisions.

7. Production judgment and bridge

If LWW is chosen, document it as an explicit information-loss policy. Observe clock offset, timestamp regressions, tie frequency, conflict rate, overwritten-value audit samples, repair behavior, and user-visible anomalies. Protect timestamp sources and reject obviously invalid client timestamps if clients are allowed to supply them. Retain enough audit history for high-value data to explain why a value won.

When two concurrent states contain independently valuable facts, the application should often merge rather than pick a clock winner. The next lesson builds that domain-aware merge path and shows when the safest resolver is a human workflow.

Check your understanding

  1. What does LWW guarantee when every replica uses the same comparison rule?
  2. Why can a physically later write lose?
  3. Does a deterministic tie-break prove the winner is semantically correct?
  4. Give a reasonable LWW use case.
  5. Why is a whole shopping cart a poor LWW register?
Review the answers

1. Deterministic winner selection/convergence for the compared values, assuming replicas see the competing versions and apply the same rule.

2. Clock skew can give the earlier write a larger timestamp, so timestamp order differs from real-time order.

3. No. It prevents replica disagreement; it does not understand business intent.

4. A replaceable/advisory value such as presence or cache-like last-seen state, when losing intermediate updates is explicitly acceptable.

5. Concurrent additions are independent valuable facts; whole-object winner selection can silently discard items.

References

Foundational claims use primary research/specifications where practical. Product documentation is used only as a current implementation example and is not required for the mandatory labs.

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.