What is reality? Does global perspective matter? Why not just your little point of view?

So first, clocks are inaccurate. Not just like to absolute time, but they also drift. And in different amounts from each other. So in distributed systems, clock synchronization is a hard problem.

Imagine you wanted to globally order transactions by what time they committed. If a clock was off, even between two nodes, we already are SOL if we use the local time as the ordering constraint:

Untitled

So given nodes A and B with TXNs $T_A$ and $T_B | T_A < T_B$ (and T1 < T2 means that T1 precedes T2), if we were to attempt to globally order the TXNs based on reported timestamp, we’d conclude that $T_B < T_A$.

This breaks causality (imagine write B depended on write A; e.g. write B was a message reply to write A).

Also, clocks aren’t just slightly inaccurate. They’re like 100s of ms inaccurate.


So imagine we were able to somehow guarantee that all the clocks are +- 3.5ms of the actual time. So ALL clocks in the system are 7ms of each other (we’ll call this e. Google actually did this, with the use of GPS + atomic clocks).

Untitled

Given this, we can actually generate a total ordering even with clocks that are off. The way we do this is when a transaction decides to commit, it waits for e time before finalizing it. Here’s a quick example of how that ends up generating the correct order (note that now the dotted lines are all e long):

Untitled

Note that if you were to follow the red circles, $T_C < T_B < T_A$. However, the actual reality (and the green squares) is that $T_A < T_B < T_C$.