The Clock Problem
Distributed databases need to order transactions globally, but every machine has a slightly different clock. Ordinary clocks drift, so you cannot trust that one server time matches another. Spanner solves this with TrueTime, an API that exposes clock uncertainty instead of pretending the clock is exact.
What TrueTime Returns
TrueTime does not return a single number. It returns an interval with an earliest and latest bound around the real time.
- The API gives earliest and latest possible times.
- The true wall clock is guaranteed to be somewhere inside that interval.
- The width of the interval is called epsilon, kept small using GPS and atomic clocks in each datacenter.
Commit Wait
To guarantee that a transaction with timestamp T is truly in the past before it becomes visible, Spanner makes the writer wait out the uncertainty. It picks a commit timestamp, then sleeps until even the latest bound has passed that timestamp. This is called commit wait and it makes timestamps globally meaningful.
Key idea
TrueTime exposes bounded clock uncertainty so Spanner can assign globally meaningful timestamps and order transactions across continents.