Unit 12 of 12 · about 4 hours · implement
Deterministic membership and network simulation
Simulation is how one machine tests a cluster. Determinism turns a flaky failure into a reproducible case the learner can argue from.
You'll be able to
- Build a seeded scheduler with delay, drop, duplicate, reorder, partition and crash faults that replays byte-identical traces.
- Run membership, detector and lease logic inside it against the DS-2 fault slice of the project list.
- Reduce a failing run to a seed plus schedule and retain it as evidence.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Deterministic faults and durable historiesReplicated Log and Stream Processor - Time and Membership Slice
Architecture constraints (deterministic schedules, durable event histories, timing-free safety tests) with the failure-injection list entries for this section: split brain attempt, clock jump, stale lease and epoch, and dual process incarnation
Read the DS-2 slice only. The log, stream and transaction entries belong to later sections.
- An external behavior contractGossip Glomers - Unique IDs and Broadcast
Challenge 3c evaluation: every broadcast value visible on every node after a partitioned run
Use as the conformance target your simulated broadcast must also satisfy. The Systems unit on distributed histories and deterministic failure simulation built the scheduler itself; extend it here, do not rebuild it.
Focus on
- Seed everything: topology, delays, drops, duplicates, reorder windows, partition intervals, crash and restart points. A run is its seed plus its schedule, and both are retained.
- Simulate time as an integer tick, never the wall clock. Timers, heartbeats and lease checks read the tick, so reruns cannot drift.
- Check fencing safety after every transition; no stale token may bypass the storage check. Membership convergence is a liveness goal, not a safety invariant, and needs eventual communication and fair scheduling. Simulated-time reads are valid for detector and lease behavior; do not require real-time bounds to establish fencing safety.
- Cover the DS-2 slice: split brain attempt, clock jump, stale lease and epoch, dual incarnation, pause and partition healing. Keep raw message and state traces, then shrink the event schedule while preserving the failure. A numerically smaller seed is not a smaller counterexample.
Common mistakes · 3
- Seeding the network but reading the wall clock in a timeout. One unseeded time source makes reruns diverge and the diff lie.
- Testing only loss-free schedules. Discovery lives in drops, duplicates, reorder and pause interleavings; the clean run is the smoke test, not the evidence.
- Keeping summaries instead of raw traces. A minimized case needs the full message history, or the next reader cannot replay the verdict.
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.Two reruns of one seed disagree. Name three unseeded sources that could explain it.Answer
Wall-clock reads, an unseeded RNG such as a default hash seed or thread race, and iteration over an unordered set or map. Fix all three before trusting any diff.
2.May a deterministic test read simulated time, and does a convergence check establish safety?Answer
Yes. Detector and lease transitions depend on simulated timers, which replay deterministically. Convergence is a liveness property under eventual-delivery assumptions; fencing safety is the separate invariant that stale tokens cannot pass the storage check.
3.A dual-incarnation bug appears once in fifty seeds. What do you keep?Answer
The failing seed, the schedule, the raw trace, and the minimized variant. The other forty-nine runs are the coverage note, not the evidence.
4.Your simulated broadcast converges under every partition schedule. Does 3c still add anything?Answer
Yes. Maelstrom drives the actual node processes through their JSON input and output with an independent workload and checker. Its network is simulated, not the production TCP stack, so it adds evidence without covering every transport fault.
You're done when
Your rerun diff is empty, the DS-2 fault slice all runs inside the harness, and one minimized case is retained with its seed.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 12 more in the section
- Gossip Glomers - Unique IDs and BroadcastFly.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 challenge 2 (unique IDs under partition with total availability) and 3a to 3c (broadcast, then with partitions). A pass shows uniqueness or convergence in that run, not ordering or recency.
- Replicated Log and Stream Processor - Time and Membership SliceRoadmap-Final · support
Add incarnation IDs, logical timestamps, gossip membership, suspicion metrics and fenced ownership. Retain seeds and minimized traces for every false-failure or stale-actor case.
Also in this section
- DDIA 2e - Chapter 9 The Trouble with Distributed SystemsMartin Kleppmann and Chris Riccomini · primary
Read clocks, pauses, unreliable networks, partial failures and knowledge limits. For each failure, record what a node observes, what is true globally and what action is safe under that uncertainty.
- Time, Clocks, and the Ordering of Events in a Distributed System (Lamport, 1978)Leslie Lamport · required
Read the partial ordering and logical clocks sections: happens-before, the Clock Condition, rules IR1 and IR2, and the total order. Its ties are broken arbitrarily, so the total order is not causality.
- Logical Physical Clocks and Consistent Snapshots (Kulkarni et al., 2014)University at Buffalo · support
Read the hybrid logical clock algorithm and its bounds; the paper reports the logical counter staying well below its proved bound in practice, so measure your own.
- SWIM: Scalable Weakly-consistent Infection-style Process Group Membership (Das et al., 2002)Cornell University · support
Read the direct and indirect probing detector, infection-style dissemination, the suspicion mechanism and incarnation numbers. Suspicion timeouts depend on the workload.
- The phi Accrual Failure Detector (Hayashibara et al., 2004)JAIST · support
Read how phi is computed from the heartbeat inter-arrival history and how a threshold trades detection time for false suspicion. Its normal approximation misleads under bursty delay, so test with pause traces too.
- How to Do Distributed Locking (Kleppmann, 2016)Martin Kleppmann · required
Read the process-pause, network-delay and fencing-token sections with DDIA 2e Chapter 9 "Distributed Locks and Leases". Treat the Redlock critique as dated to 2016; the lasting lesson is that the storage service must reject a write that carries an older token.
- Cambridge Concurrent and Distributed Systems Notes (Kleppmann) - Time, Clocks and OrderingUniversity of Cambridge (Martin Kleppmann) · support
Use Chapter 3 (physical clocks, NTP and monotonic clocks, happens-before) and Section 4.1 (Lamport and vector clocks with worked examples) as the derivation workbook: work Exercises 7 to 13. Each section marks where its public lecture video starts.
- Building Distributed Systems - The TimekeeperBuild Distributed Systems · optional
Only the first three tasks are free (clock reads and backward jumps, a monotonic wrapper, a split-brain lease). Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.
- Building Distributed Systems - The GossiperBuild Distributed Systems · optional
Only the first three tasks are free (basic broadcast, tree topology, random gossip). 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 - Clocks, Failure Detection and Consistent HashingHLD Handbook · required
Read Part 3 clocks and ordering, failure detection and consistent hashing. Use its exercises to compare assumptions, then verify claims against your own histories.
- MIT 6.5840 - Failure and Paper Discussion LensMIT PDOS · support
Use the RPC, GFS, Raft and consistency lectures to identify which timing assumptions affect progress and which invariants must not depend on time. Do not start the Raft lab yet.
- AlgoMaster System Design practice - clock, gossip and lease drillsAlgoMaster · support
Use only the named problems: Advance a Lamport Logical Clock, Compare Two Vector Clocks, Update a Vector Clock on Receive, Advance a Hybrid Logical Clock, Simulate Gossip Rumor Spread and Implement a Lease Lock with Fencing Tokens. Each states its function signature and checks small deterministic cases.