Make real-time uncertainty part of the commit protocol
Reason from guaranteed time intervals to a commit-wait condition without treating synchronization or sleeping alone as a transaction protocol.
On this page
The question for today
What you’ll understand
- Distinguish a guaranteed time interval from a typical error estimate.
- Apply an earliest-bound-after-timestamp condition and explain its purpose.
- Separate commit waiting from locking, replication, and transaction-ordering requirements.
A database can expose clock uncertainty rather than pretending every timestamp is exact. An interval containing real time lets a protocol ask whether a chosen commit timestamp is certainly in the past. Waiting until that answer is yes can help align transaction timestamp order with observable real-time completion. The condition is powerful because it is conservative, but it works only as part of a complete protocol whose intervals and transaction rules satisfy their stated assumptions.
An interval is useful only if containment is justified
Suppose a time API returns earliest and latest bounds with a contract that real time at that call lies between them. Their midpoint is an estimate; their width is uncertainty. The protocol must rely on containment, not merely on the historical frequency with which the midpoint was close. If a clock source is lost, the interval may need to grow or the service may need to stop making a time-sensitive claim. Keeping a narrow interval while the actual guarantee has failed makes the caller's otherwise correct interval comparison unsafe.
Two event intervals that overlap do not determine their real-time order. If one interval lies wholly before another, their actual times are ordered under the containment contract. This differs from happened-before: physical precedence alone does not establish a communication path. In a transaction system, the desired property concerns observable starts and completions as well as timestamps. Define those boundaries explicitly. A timestamp assigned during processing is not the same event as a client learning that its transaction completed, and uncertainty between these events is exactly what the waiting rule addresses.
Choose a timestamp and wait for the required fact
In the Spanner design, a coordinator chooses a transaction timestamp subject to protocol constraints, including a lower bound related to the current latest possible time. It prevents the relevant commit from becoming observable until the time API can establish that the timestamp is in the past. The essential after test uses the earliest current bound: only when that bound exceeds the chosen timestamp is every possible current real time later. Checking only the midpoint or latest bound would leave some allowed real times on the wrong side of the timestamp.
The protocol also needs ordering of assigned timestamps, transaction locking and validation, replication, and the other commit rules described by the design. Waiting on a clock cannot make a partially replicated write durable, resolve a transaction conflict, or replace atomic commit. It supplies one real-time ordering fact inside that larger argument. Some waiting can overlap work already required for replication, so a synthetic uncertainty width is not automatically extra end-to-end latency added after all other work. Distinguish the condition that must eventually hold from a prediction of how a particular implementation schedules its stages.
A wider bound changes both waiting and confidence
If uncertainty is symmetrically bounded by epsilon around a steadily advancing estimate and the chosen timestamp equals the initial upper bound, the lower bound must advance by more than twice epsilon to pass that timestamp in the simplified model. Real systems can change uncertainty, choose a later timestamp for another reason, or overlap the wait with communication. Do not publish one universal fixed commit-wait duration. Monitor the health of the uncertainty contract and the chosen timestamp constraints, then measure how much waiting remains on the actual critical path under the deployed workload.
The root-finding lab illustrates what a valid bound means, not how clocks are synchronized. Reset, set both target c=2 and upper bound U=3, predict the bracket half-width after three bisections, then Step three times. The positive root remains inside a bracket whose midpoint error bound falls from 1.5 to 0.1875. This guarantee comes from the monotone quadratic and preserved bracket. A clock interval instead requires evidence about time sources and drift; numerical bisection cannot shrink it. The useful shared idea is that a decision justified by a bound depends on why the bound contains the unknown value.
Work it through
Wait for the earliest bound, not the midpoint
A hypothetical clock API initially returns[100, 108] ms, and the protocol chooses s=108 ms. Assume the whole interval translates forward one millisecond per physical millisecond while retaining its width. Other commit conditions are already satisfied for this exercise. Inspect the wait at elapsed 7 ms and 9 ms.
Initially, real time may lie anywhere from 100 through 108 ms. Choosing 108 places the timestamp at the upper bound, but does not yet establish that it is in the past.
After 7 ms in the stated model, the interval is[107, 115] ms. Its earliest bound 107 is not greater than 108, so the after condition remains false even though the midpoint exceeds the timestamp.
After 9 ms, the interval is[109, 117] ms. Now 109>108, so the required after condition holds. The calculation illustrates the strict bound comparison, not a production latency guarantee.
The 7 ms check must wait; the 9 ms check can pass the time condition. A midpoint-only test would have admitted uncertainty that the specified protocol excludes.
The living notebook
Explore the model
Interactive lab · root-finding
A bound needs a mechanism that preserves containment
Reset, set both c=2 and U=3, predict the midpoint error bound after three bisections, then Step three times. The analytic positive root stays bracketed, with error bound 0.1875 after those three iterations. This quadratic bisection instrument does not estimate clock error or simulate commit waiting.
- Midpoint after 0 refinements
- 1.5
- Bracket error bound
- 1.5
- Computed residual · x² − c
- 0.25
Bisection of x² − c on [0,U], capped at 50 iterations for floating-point resolution. The error bound is the maximum distance from the displayed midpoint to either bracket endpoint (half the width in exact arithmetic). Compensated square evaluation preserves the bracket when ordinary multiplication rounds a residual to zero. A truly exact endpoint or midpoint collapses the bracket. This is one monotone quadratic, not a general root solver. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forBound-based decisions need a valid containment argument. A numerical root bracket and a calibrated time interval obtain that guarantee from different mechanisms.
Pause & reason
Check your understanding
Your turn
Try it yourself
In a simplified model, the initial interval is[40, 52] ms and s=52 ms. It translates forward at one millisecond per physical millisecond with constant width. Does exactly 12 ms of elapsed time satisfy earliest>s?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Compute the translated lower bound and preserve the strict comparison.
Compare with the solution
After exactly 12 ms the interval is[52, 64] ms, so earliest equals s and the strict condition is not yet true. It holds after more than 12 ms in this particular model, subject to observation granularity and the stated assumptions.
Keep the idea
Take it with you
- A guaranteed time interval is a protocol contract, not a typical-error claim.
- Commit waiting checks whether the earliest possible current time has passed the chosen timestamp.
- Time ordering works with the transaction protocol; it does not replace replication or atomicity.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.