Skip to main content
Lexicon
Lexicon

TrueTime API (Clock Uncertainty Interval)

Difficulty: Advanced
3 min read

In plain English

Plain definition

TrueTime is a clock service that, instead of giving you a single time value, gives you a guaranteed range within which the true time falls. Distributed transactions use this range to safely wait out any uncertainty before confirming a commit, so that later transactions are guaranteed to see earlier ones — without needing to negotiate timestamps across machines.

Conventional NTP-synchronized clocks return a point estimate with an unbounded and unknowable error. TrueTime instead returns TT.now() -> [earliest, latest], an interval derived from hardware time sources (GPS receivers and atomic clocks distributed across datacenters) combined with a rigorously bounded worst-case drift rate (in Spanner’s original implementation, epsilon varied as a sawtooth between about 1 and 7 ms, averaging about 4 ms, with a worst-case drift assumption of 200 microseconds per second). Every timestamp assignment in the system is accompanied by an explicit uncertainty bound, and the system architecture is built around never trusting a timestamp until the uncertainty window has provably elapsed.

The mechanism that makes this useful is commit-wait. When a transaction commits with timestamp s, the coordinator does not release the commit acknowledgment until TT.after(s) is true — i.e., until TT.now().earliest > s. This guarantees that by the time any client can observe the effects of the transaction, real time has actually advanced past s on every node in the system, regardless of local clock skew. This is what enables Spanner’s external consistency guarantee: if transaction T2 starts after T1 commits (in real time), T2 is guaranteed to see T1’s effects, Spanner still uses two-phase commit, Paxos and locking for read-write transactions; TrueTime only removes the need for a separate clock-agreement protocol.

The architectural cost is real and non-negotiable: expected commit-wait is on average at least about 2 * epsilon, as the Spanner paper describes, so the system’s commit latency is hostage to the tightness of the uncertainty bound. This is why TrueTime is inseparable from specialized hardware — GPS/atomic clock reference stations (‘time masters’) per datacenter, with client-side daemons (timeslaved) polling multiple masters and applying a bounded worst-case drift extrapolation between polls. A time master failure, GPS antenna fault, or leap-second mishandling doesn’t cause incorrect answers (the interval semantics are safety-preserving), but it does widen epsilon and directly inflates commit-wait latency across the fleet — a textbook case of a non-functional infrastructure dependency leaking directly into transactional throughput.

The broader lesson generalized beyond Spanner: TrueTime and Hybrid Logical Clocks make different trade-offs. TrueTime enables external consistency via commit-wait, whereas HLC only orders observed causal relationships via message passing, while TrueTime bounds the relationship between timestamps and real time. Systems like CockroachDB explicitly forgo TrueTime hardware and instead accept a hybrid approach — HLC plus an uncertainty interval bounded by max clock offset — which avoids commit-wait but provides serializability with a weaker real-time ordering guarantee than strict serializability (it does not offer external consistency), and requires read-side uncertainty restarts when a transaction’s read timestamp falls inside another transaction’s ambiguity window.

About this page

Credited to

Dates

Published

Corrections

  • : Corrected during a review of published articles. Details

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

More from KBY that goes with this term.

What Is TrueTime API (Clock Uncertainty Interval)?