Two servers each write a record stamped with its own clock. Why can you not use those timestamps to decide which write happened first, and what do you use instead?
Answer
Short answer
Wall clocks on separate machines disagree by an unbounded amount and can jump backwards, so their timestamps order events by accident rather than by causality. Logical and vector clocks capture what preceded what, quorums give overlap not order, and a lease is safe only with a fencing token.
Logical clocks are useful because they record causal order without pretending there is one global time. Good logical clocks reasoning explains when Lamport clocks are enough and when vector clocks are needed. Weak logical clocks answers sort timestamps and miss concurrent events.
Logical clocks give the system a way to reason about before and after without inventing perfect time.
Was this answer helpful?
Likely follow-ups
- Your store resolves conflicts by keeping the write with the higher timestamp. What is the failure you have accepted?
- Vector clocks grow with the number of writers. How would you bound that in practice?
- Under what conditions can you legitimately order events by physical time?
- How does a follower know the leader it is talking to is still the leader?
Related questions
- CAP says you must choose between consistency and availability under a network partition. What are you giving up, concretely?hardAlso on quorum4 min
- Your service writes a record, reads it straight back, and sometimes gets the old value. What is happening and what do you change?hardAlso on quorum5 min
- Design a distributed job scheduler that runs every job once, and on time, even when workers die.hardAlso on clock-skew5 min
- One machine's clock is ninety seconds ahead of the rest of the plant. Which of your numbers are wrong, and how would you have found out?hardAlso on clock-skew7 min