skip to content

Last-write-wins is popular because it's simple and requires no application involvement. Walk through at least three concrete ways LWW can silently lose committed data or violate causality in production, and describe one situation where you would deliberately choose LWW anyway despite these risks.

level: seniorimportance: must knowfreq 60%

answer

  1. clock skew flips order
  2. whole-row clobber
  3. delete vs update race -> zombie writes
  4. tombstones for safe deletes
  5. fine for freshest-value-only fields

basics

~20 s

Last-write-wins can quietly throw away real changes when clocks disagree, when a whole record gets overwritten instead of just the changed part, or when a 'delete' loses to an older 'update.' It's still fine to use when only the newest value ever matters, like a cache or a heartbeat.

solid answer

~50 s

LWW's core risk is that it converts a rich causal question ('which write logically supersedes the other?') into a single scalar comparison ('which timestamp is bigger?'), which breaks in at least three concrete ways: clock skew can make a causally later write lose to an earlier one; whole-row or whole-document comparison can silently discard an unrelated field change bundled with the losing write; and delete-vs-update races can resurrect deleted data or permanently drop an update, depending on which one's timestamp happens to be later. None of these produce errors — they produce a quietly different final state, which is what makes LWW dangerous for anything the business cares about losing. It's still the right choice for high-volume, low-stakes fields where only the freshest value matters and paying for vector clocks or a merge function isn't worth it — session heartbeats, presence/last-seen fields, ephemeral caches, or metrics where an occasional lost sample doesn't change the aggregate.

go deeper

for a junior

Should be able to name at least one way LWW can lose data (e.g., clock skew) when prompted, and say that the loss raises no error.

for a middle

Should be able to describe two of the three failure modes concretely and know deletes need tombstones, not plain LWW.

for a senior

Should discuss all three failure modes with mechanism-level detail, say what clock synchronization and hybrid logical clocks do and do not fix, and articulate a clear rule for when LWW is/isn't acceptable.

for a principal

Should be able to set a policy (which classes of fields default to LWW vs require merge/CRDTs) and design tombstone retention / clock-sync SLAs that bound the risk organization-wide.

## What the single comparison discards Last-write-wins collapses conflict resolution to a single comparison — pick the write with the larger timestamp — which is attractive because it requires no extra metadata beyond a clock reading and no application involvement, but that same simplicity is exactly what causes its failure modes: it discards the causal information that would let the system tell the difference between 'this write is genuinely newer' and 'this write merely has a larger number attached to it.' ## Three failure modes 1. **Clock-skew-induced causality violation** — the first failure mode. If node A's physical clock runs ahead of node B's, a write accepted by A can carry a timestamp later than a write accepted by B even when B's write causally happened after A's — for instance, a client reads A's write and then deliberately issues a follow-up write to B a second later in real time, yet A's skewed clock still stamps its (earlier) write with a larger number. LWW then keeps A's stale write and discards B's intentional follow-up, and nothing in the system flags this as wrong: it's a valid-looking write with a valid-looking timestamp, just the wrong one. This is why a store that relies on LWW depends on synchronized clocks (NTP): the further clocks can disagree, the larger the gap within which a later write can be stamped lower and lose. Synchronization narrows that gap without closing it, and a hybrid logical clock removes the inversion only for writes whose cause reached them through the system's own messages (here, only if B's write carries the timestamp the client read from A). 2. **The unit of comparison** — the second failure mode. An LWW implementation that compares and swaps an entire value — a whole row, a whole document — rather than individual fields, because tracking timestamps at finer granularity costs more metadata, turns unrelated changes into conflicts. When two clients concurrently modify different fields of the same record starting from the same base version, whole-value LWW keeps one client's entire document and discards the other's entirely, even though the two changes didn't logically conflict at all — a user changing their bio and, seconds later on a different device that has not yet seen that change, changing their avatar can end up with only one of the two changes surviving, purely because of write ordering unrelated to the actual conflict. Cassandra, for one, keeps a separate timestamp for every column of every row, so concurrent updates to different columns both survive; two concurrent writes to the same column still lose one. 3. **The delete/update race** — the third failure mode, and an operationally painful one. Because a delete is just another write competing on the same timestamp axis, a concurrent update and delete of the same key resolve however their timestamps happen to compare, with no special-casing for the fact that 'deleted' is a different kind of state than 'has a value.' If the delete's timestamp is later, the record correctly disappears; if a stale update happens to carry a later timestamp than the delete (which happens with clock skew, or when the store stamps a write on arrival and the update was delayed, in a queue for instance, until after the delete), the deleted record can silently reappear — a 'zombie' write — well after the user thought it was gone. Tombstones do not stop that case, since the update's timestamp is the later one; they stop the opposite one: kept with their own retention and compaction rules, a tombstone gives a late-arriving update with an earlier timestamp something to lose against within the retention window, where a physically removed record would be recreated. ## Why the damage stays invisible None of these three failure modes produce an error the application can catch — they all manifest as a quietly different final state, discovered later (if ever) as a confused support ticket, a re-appearing deleted item, or a change that 'didn't stick.' ## When LWW is still the right choice That said, LWW remains the right engineering choice for a large class of data precisely because these failure modes are tolerable there: - **session heartbeats and presence/'last seen' fields** only ever care about the freshest value, so losing a stale concurrent write is definitionally correct behavior, not a bug; - **high-volume metrics or cache entries** can tolerate an occasional lost sample without changing any aggregate a human relies on; - **the operational simplicity** — no per-key metadata growth, no sibling management, no merge functions to write and test — is a real, ongoing cost saving at scale. The engineering judgment call is asking, for each field, 'if this write silently disappears with no error and no notification, does anyone's outcome change?' — if the answer is no, LWW is the pragmatic default; if the answer is yes (money, inventory, user-authored content, anything representing an operation rather than a value snapshot), it's the wrong tool and the cost of vector clocks plus a merge function, or a CRDT, is money well spent.

  • Under last-write-wins, does a tombstone stop an update made without seeing the delete if the update carries the later timestamp?
    No. Under last-write-wins a tombstone is compared like any other write, by its timestamp: it hides values stamped before it, and an update stamped after it overwrites it, so the record comes back with what that update wrote. A timestamp records when a write was stamped, not what its writer had seen, so last-write-wins cannot tell a deliberate re-create from an update made without seeing the delete.
  • Would using a hybrid logical clock instead of a raw wall clock eliminate the clock-skew failure mode?
    No. An HLC guarantees that if one event happened before another through messages carrying the clock, the later one gets the larger timestamp, whatever the skew, so a follow-up write whose node has seen the first write's timestamp wins as it should. It does not help when the cause travelled outside the system (a phone call, another service), and two truly concurrent writes are still ordered by their physical clocks, so LWW still drops one of them.
  • If a team decides LWW is unacceptable for a field, what's the cheapest next step up before jumping to full vector clocks and application merge?
    Field-level (rather than whole-row) timestamps, if the store supports them, remove the granularity failure mode cheaply without adding a new mechanism. For the delete/update race specifically, adopting tombstones with a sane retention window addresses that one failure mode directly. Only if the data genuinely needs to preserve two independent concurrent writes (not just 'apply the more recent field-level change correctly') is the jump to vector clocks plus a merge function actually necessary.

It's like a shared inbox where only the message with the latest postmark is kept and all others are shredded unread — fine if the inbox only ever needs 'the newest memo,' disastrous if two people mailed genuinely different, both-important updates on the same day.

  • Claims LWW is always wrong / never appropriate
  • Doesn't know deletes need special handling (tombstones) under LWW
  • Thinks tighter clock sync fully eliminates LWW's risk rather than narrowing it
  • Can't name a scenario where LWW is the correct pragmatic choice
  • Assumes LWW failures would show up as visible errors

context