~learn.
0:00 / 1:16
W01 · Data at scale

You refreshed, and your data went back in time

transcript

You refresh a thread. Version 5. You refresh again. Version 3. Your data just went back in time.

Every write goes to the leader. Followers copy it, each at its own pace. Your first read lands on follower A. It's caught up. Version 5. Your second read lands on follower B. It's lagging. Version 3.

Two reads, two replicas, two different lags. The fix: read from the same replica for the whole session. Then you only ever move forward.

But here's a weirder one. Message A is written at 9:00. B, a reply to A, at 9:01. A follower receives B first. Read it now… …and you see a reply to a message that doesn't exist.

That's two named anomalies. Monotonic reads: time never runs backwards. Consistent prefix: replies never come before what they answer. Fix: send related writes through the same partition or leader. Or use logical clocks.

Replication lag doesn't just make data old. It makes it go backwards, and out of order. Pick which ones you can live with.

Full breakdown in the lecture.