Spanner buys certainty by paying for it in waiting

now >= ts + eps -> visible

Spanner does not know the time, so it measures how wrong its clock might be and hides each write until that error has passed.

Timestamps from different machines cannot order the events they describe, because local clocks drift. Spanner assigns each commit an uncertainty interval and waits until that interval has passed before making the write visible. The consequence is that every write pays its own error bar in latency, and causally dependent writes receive increasing timestamps, so readers never see a reply without what it answers.

The commit path reads the clock as an interval, not a point. Each datacenter runs clocks synchronized tightly enough that the interval stays a few milliseconds wide, and Spanner stamps the commit with a timestamp inside that interval. Before the write becomes visible, the system waits until the interval has passed on its clock. When the wait ends, every clock in the system has moved beyond the stamp's upper bound, so any later commit must receive a larger timestamp. The transaction itself does not change during the wait. Only its visibility moves, and the width of the interval sets how far.

The abstraction hides how fragile the guarantee is when the wait is skipped. Suppose a commit stamps its write with a local time that trails the true time, and no wait corrects it. A later commit that depends on the write stamps itself higher, so sorting by timestamp places the reply before the comment it answers. A reader that asks for everything up to a given timestamp receives the reply without its parent. Nothing crashes, no lock times out, and no error reaches the application. Cross-region round trips in tens of milliseconds make the wait feel expensive, which is exactly why teams are tempted to remove it.

Use timestamp ordering only when you can bound the clock error, and measure that bound before you design around it. Ask for the worst drift between your machines under load, then set the wait to that figure rather than to an average. If the bound is a few milliseconds, accept the wait for writes that must be ordered across regions. If your machines run on virtual hardware with drifting clocks and no trusted time source, the wait becomes your worst observed drift, so choose locks or accept reads that admit staleness instead. Check that the bound comes from hardware you control, because the ordering is only as correct as the claim behind it. Spanner's design does not port to arbitrary hardware.

orders of magnitude
Clock uncertainty
a few ms

The width of the interval Spanner assigns to each timestamp on GPS-backed clocks. A narrower bound means a shorter commit wait.

Commit wait
equal to the interval

The delay before a commit becomes visible. The wait is the cost of proving order rather than guessing it.

Cross-region round trip
tens of ms

The network time one write spends reaching another region. The commit wait stacks on top of this for every cross-region write.

Unbounded local drift
no fixed value

Error in a clock with no external sync, which cannot be bounded and so cannot support a finite commit wait.

field note

The naive design treats ordering across regions as a clock problem. Each commit receives the local time of the machine that handled it, and the database sorts commits by that stamp. On one machine this works, and across datacenters it looks reasonable, since each clock seems accurate enough for everyday use.

The wall arrives when clocks disagree. A transaction on a machine whose clock runs behind carries an earlier stamp than a transaction that depends on it. A reader can then see a reply committed before the comment it answers. Nothing signals the fault, because every stamp looks valid on its own.

The fix was to stop pretending that stamps are exact. Each timestamp carries an uncertainty interval, and the system waits until that interval has passed before making the commit visible. The wait is bounded by a clock error measured from tightly synchronized hardware, so the cost is known rather than hoped for.

The lesson is that latency can buy certainty. Spanner does not eliminate clock uncertainty. It pays for it in waiting and makes the price explicit, which is what turns the ordering guarantee into something an engineer can check.