What are monotonic reads, how can replication break them, and how do you guarantee them?
Sketch your own answer first, then compare it with the one below.
A strong answer
Monotonic reads says that once a client has seen a value, later reads by that client never return an older one.
Replication breaks it when successive reads land on different followers with different lag. The first read hits a follower that is current and the second hits one that is behind, so the client appears to go back in time. A comment appears and then vanishes on refresh.
The simple fix is to pin each client or session to a single follower, for example by hashing the client id, because one follower only moves forward. If that follower fails the client moves to another and may see a step back once. A stronger method has the client remember the highest log position it has seen and require followers to be at least that far along.
Pinning does not give read-your-writes, because the pinned follower can still be behind the client's own write. The two guarantees are separate, and a store can offer both.
Sources
- Douglas Terry, Alan Demers, Karin Petersen, Mike Spreitzer, Marvin Theimer, Brent Welch (1994). Session Guarantees for Weakly Consistent Replicated Data.