Database / Google Spanner Database Interview questions
Why does Spanner use TrueTime for consistency?
Spanner needs to order transactions correctly across machines that may be thousands of miles apart, and clocks on separate servers naturally drift, so a plain local timestamp can't be trusted to reflect real-world order. TrueTime solves this by exposing clock uncertainty explicitly, as an interval, instead of pretending clocks are perfectly synchronized.
When a transaction commits, Spanner picks a timestamp and then waits until it is certain that timestamp has passed everywhere, the "commit wait" period equal to the uncertainty bound. This guarantees that if transaction B starts after transaction A commits, B's timestamp will be greater than A's, which is the definition of external consistency. Without TrueTime, Spanner would need a slower consensus round trip on every single commit just to establish ordering, which is why TrueTime is central to keeping global transactions both correct and fast.
More Related questions...