Menu

The Lamport Timestamp Trap: Ordered Numbers Aren't Causality
📰

The Lamport Timestamp Trap: Ordered Numbers Aren't Causality

DEV Community: backend·Darshan Turakhia·10 days ago
#cC39svVr
#devtobackend#devto#dev#events#different
Reading 0:00
15s threshold

I spent an embarrassing amount of time last year debugging a reconciliation bug that turned out to be a logic error I'd made months earlier, in my own head, about what an ordering guarantee actually promises. The short version: I assumed that because event A's timestamp was smaller than event B's, A must have caused or at least preceded B in some meaningful sense. It hadn't. The two events had nothing to do with each other. They just happened to land on different integers.

That's the trap built into Lamport timestamps. It's worth understanding precisely because the mechanism is so simple you can hold the whole thing in your head in about thirty seconds, which makes it easy to assume you've understood everything it does.

Here's the setup. Every node in a distributed system keeps one counter, starting at zero. Two rules update it. Any local event, a write, a log entry, a state change, bumps the counter by one.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.