Option 2: Async Replication and the Out-of-Order Problem

US commits name=hat and India commits name=sat, each locally and immediately. Each then ships its WAL entry to the other node in the background. Both nodes eventually receive the other's write, and the conflict is detected only then.
Both sides commit at once; the conflict surfaces only when the shipped entries cross

Why Entries Arrive Out of Order

Under async replication there is no single sequencer deciding "this happens before that" — each node ships its WAL entries the moment it commits, over a network with variable latency. A packet can queue behind other traffic, take a slower route, or get retried after a drop. The result: the order entries are generated in is not the order they arrive in at a remote node. This is different from the clock-drift problem in the Multi-Master Problem part — HLC already gives every entry a correctly ordered timestamp. The problem here is that a correctly-timestamped entry can still show up late, after the node has already moved on and applied later entries.

Does It Actually Matter? Three Scenarios

Late arrival is only a problem under specific conditions. Walk through when it does and doesn't matter:

ScenarioExampleDoes late arrival matter?
Different keysUS writes name=hat, India writes city=BOMNo. Each key's value is independent — applying city=BOM late has no effect on name. Order across keys never matters.
Same key, causally relatedIndia reads name=hat (already replicated from US), then writes name=hat-redNo. India's write has a strictly higher HLC because it observed the US write first (The Multi-Master Problem's whole point). Applying by highest-timestamp-wins reproduces the correct causal order even if messages arrive late.
Same key, concurrentUS writes name=hat and India writes name=sat at nearly the same instant, neither having seen the other's writeYes — this is the hard case. There is no causal relationship to reconstruct. Whichever one a node applies first is arbitrary, and a second, unrelated local write can land on top before the remote one even arrives.

The walkthrough below is the third case — the only one that actually requires a resolution strategy (see Conflict Resolution Strategies).

Walking Through the Hard Case

Timeline of the hard case. India log: name=sat at t=100, then name=shi at t=110, which India writes before the US entry arrives. US log: name=hat at t=101, slow to replicate due to network lag. The US entry reaches India only after India has already applied t=110, so an entry with an earlier timestamp arrives later.
Generated second, delivered last — “hat” reaches India after “shi” is already applied

India applies its own log in order: t=100 → "sat", t=110 → "shi". India's database now shows "shi". Then — late — US's entry name="hat" (t=101) finally arrives, after India has already moved past t=101 and committed t=110. From India's point of view, an entry timestamped earlier than what it already applied just showed up.

What The Node Actually Does With It

Two separate questions get answered in two separate steps — conflating them is the usual source of confusion:

  1. Step 1 — Append to the log. Unconditional, always happens. The moment India receives the entry, it appends name="hat" (t=101) to the end of its local log, at the log position corresponding to when it arrived — not t=101, which is when it was generated. This is just India durably recording "I received this write." It happens regardless of what the entry contains, how late it is, or what the current state says. Nothing has been decided about name's value yet.
  2. Step 2 — Apply to state. Conditional, decided separately. Applying is a distinct operation: look up the current value for key name — "shi" — and decide whether this newly-appended entry should overwrite it. India does not replay t=100 or t=110 to do this; it only ever compares against the single current value.
  3. The resolution strategy decides step 2's outcome. The comparison ("shi" @ t=110 vs. "hat" @ t=101) is resolved by LWW or vector clocks (see Conflict Resolution Strategies). That decision determines whether "hat" gets applied (overwriting state) or not (state stays "shi", with "hat" surfaced as a conflict) — but either way, the entry is already sitting in the log from step 1, permanently, as a record that it happened.