Unit 4 of 14 · about 4 hours · explain, implement
Stale reads, read-your-writes and monotonic read and write guarantees
The Systems unit on consistency models and conflict resolution classified session histories. Here the new work is the eligibility test, including what happens when no reachable replica contains the session's dependencies.
You'll be able to
- Separate read-your-writes, monotonic reads, monotonic writes and writes-follow-reads using histories.
- Implement a session frontier that routes or waits for a sufficiently advanced replica.
- Diagnose a session violation after rerouting or losing client context.
Covers
Read
In this order, only the parts listed
0 of 2 done
- DDIA, 2nd edition: replica routing for sessionsDDIA 2e - Chapter 6 Replication and Chapter 10 Consistency Sections
Chapter 6, Replication: Problems with Replication Lag through Solutions for Replication Lag, pp. 209 to 215
Use the familiar stale-read examples as routing tests, not a second introduction. Stop before Multi-Leader Replication.
- Terry et al. (1994): session contracts and enforcementSession Guarantees for Weakly Consistent Replicated Data (Terry et al., 1994)
Sections 3.1 to 3.4, the four guarantees; Section 4, Providing the guarantees; Section 5, Practical implementation of the guarantees, including Figure 1
Focus on
- Read-your-writes requires a read view that includes the session's prior writes, not necessarily their unchanged values after other writes supersede them.
- Monotonic reads tracks previously observed history. Monotonic writes orders the session's writes at replicas; writes-follow-reads carries dependencies from reads into later writes.
- Use an applied log position for a single ordered lineage or a dependency vector for multiple origins. A frontier must describe a complete prefix, not merely the largest event observed.
- The paper's enforcement relies on ordered propagation and session metadata. If no eligible replica is reachable, preserve the guarantee by waiting or failing rather than silently using a stale one.
Common mistakes · 3
- Using sticky routing as a complete guarantee when the chosen replica can restart, roll back or be replaced.
- Comparing returned numeric values to test monotonic reads. A later legitimate write may lower the value.
- Confusing the order in which the client sends writes with the order in which every replica exposes them.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Can a session satisfy monotonic reads while always reading stale data?Answer
Yes. Its observed histories must not move backward, but they need not be globally current.
2.Does read-your-writes alone require a replica serving a later write to include all earlier reads?Answer
No. Writes-follow-reads carries those read dependencies into the write. Read-your-writes constrains subsequent reads relative to the session's writes.
3.Why can satisfying a session guarantee reduce availability after a partition?Answer
The reachable replicas may lack the required history. Serving them immediately would violate the guarantee, so the operation must wait, fail, or reach an eligible replica.
4.Does a write on a phone automatically enter the browser's session token?Answer
No. Cross-device guarantees need a shared or transferred session context. A common user name alone does not transfer dependencies.
Practice
- AlgoMaster: Route Session-Consistent Replica Reads
recordWrite,advanceReplicaandrouteRead: a replica is eligible for read-your-writes only when its applied LSN reaches the session's greatest write LSN, with the primary as the fallbackPremium, on a subscription the learner owns. The judge falls back to the primary; your loglab router should also offer waiting or failing, and add monotonic reads and context loss on rerouting.
- AlgoMaster: Validate Session Consistency
isConsistentover one session history of per-key versioned reads and writes, checking read-your-writes and monotonic readsA free warm-up. It tracks a per-key high-water version, not a log prefix, so it cannot express monotonic writes or writes-follow-reads.
You're done when
Your session tests reject an ineligible replica after both a write and a read, and distinguish monotonic-write ordering from read-your-writes visibility.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 14 more in the section
- DDIA 2e - Chapter 6 Replication and Chapter 10 Consistency SectionsMartin Kleppmann and Chris Riccomini · primary
Read replication completely, then the consistency-model and linearizability portions of Chapter 10. Convert every named guarantee into allowed and forbidden histories before selecting implementation policy.
- Session Guarantees for Weakly Consistent Replicated Data (Terry et al., 1994)Cornell course copy · support
Read the definitions of read your writes, monotonic reads, writes follow reads and monotonic writes and how each is enforced. They hold per session, not system-wide.
Also in this section
- Linearizability: A Correctness Condition for Concurrent Objects (Herlihy and Wing, 1990)ACM TOPLAS (MIT 6.5840 copy) · required
Read through Section 3.1, as MIT 6.5840 assigns: histories, real-time order and the definition every history check in this section tests. Linearizability is per object, which is why it composes.
- Dynamo: Amazon's Highly Available Key-value Store (DeCandia et al., 2007)Amazon (author copy) · required
Read the background and system architecture sections: consistent hashing, replication, vector-clock versioning, sloppy quorums, hinted handoff and Merkle-tree anti-entropy. alone does not make it linearizable, and its numbers are 2007 production results.
- Brewer's Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services (Gilbert and Lynch, 2002)CMU course copy · support
Read the model and the asynchronous-network theorem, then the partially synchronous discussion. Availability here means every request a non-failing node receives gets a response, in every fair execution, including executions that lose messages.
- Don't Settle for Eventual: Scalable Causal Consistency for Wide-Area Storage with COPS (Lloyd et al., 2011)Carnegie Mellon University (author copy) · support
Read the causal+ definition and the dependency-tracking mechanism; causal+ adds convergence to causal consistency, so keep the qualifier.
- Conflict-free Replicated Data Types (Preguica, Baquero and Shapiro, 2018)arXiv · support
Read it for the state-based and operation-based vocabulary and the delivery assumptions each needs; the implementation belongs to DS-9.
- Consistency in Non-Transactional Distributed Storage Systems (Viotti and Vukolic, 2016)arXiv · support
Use it as a map of model names and their relations, then confirm any single definition against its primary source.
- MIT 6.5840 - Consistency, Linearizability and Replication PapersMIT PDOS · required
Use Spring 2026 lectures 8, 12 and 13 plus their Linearizability, Spanner and Chain Replication readings. Write one history question per mechanism and answer it before looking at the discussion material.
- Cambridge Concurrent and Distributed Systems Notes (Kleppmann) - Replication and LinearizabilityUniversity of Cambridge (Martin Kleppmann) · support
Use Chapter 5 (quorums and replication with broadcast) and Section 7.2 (linearizability and ABD) as a derivation workbook: work Exercise 19 (ABD pseudocode) and Exercise 20 (is this execution linearizable?) before writing your own checker.
- Building Distributed Systems - The StoreBuild Distributed Systems · optional
Only the first three tasks are free (the key/value interface, client routing and read consistency). Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.
- HLD Handbook - Consistency, Quorums, Replication and Anti-EntropyHLD Handbook · required
Read Part 1 consistency plus Part 2 replication and Part 3 consistency, quorums, CAP and PACELC, clocks and Merkle trees. Use the chapter exercises as oral review after implementing the histories.
- Jepsen Consistency ModelsJepsen · required
Use the model hierarchy and history definitions to name the exact contract being checked. Check recorded single-register histories with Knossos, which Maelstrom runs for its
lin-kvworkload, and never claim a stronger model than the checker covers. - Gossip Glomers - Broadcast and Grow-Only CounterFly.io and Jepsen · required
Each challenge runs locally under Maelstrom (v0.2.4; the pages were tested on 0.2.3) with its checker and, where the page says so, the partition nemesis; keep the run directory as the history. Do 3d and 3e (efficient broadcast, with message and latency budgets) and 4 (a grow-only counter over sequentially consistent storage). Explain why convergence alone does not imply linearizability or transaction isolation.
- Replicated Log and Stream Processor - Replication SliceRoadmap-Final · support
Add configurable replication, lag, failover, recorded histories, repair and a checked consistency contract. Preserve one violating history and the fix or narrowed claim.
- Vector Clocks Revisited Part 2: Dotted Version VectorsRiak - Russell Brown · support
Read Sibling Explosion through Dot The clocks for the per-sibling dot and incoming-context replacement rule. This fills the implementation gap left by DDIA's brief dotted-vector mention; use the 2015 example, not its product-default statements as current guidance.