The problem
A journal needs many values in order, not one. Two phases per record cost two round trips, and proposers that fight over each slot make no progress.
The story
Each slot of the log is one single-decree Paxos. A leader runs Phase 1 once for every
slot from the first one it does not know. After that, a write is only Phase 2 in the next
free slot. A Commit tells the followers which slots are chosen, and the heartbeat says how
far the log is chosen. The story ends with a choice of faults: a leader crash, a lost slot,
lost Commits, a node that falls behind, a leader that stops before or after its disk write,
an old leader, a second crash during a recovery, a node that misses a truncation, a handoff,
reads, and “Break the rule”, where a node skips Phase 1. Continue plays the next screen, and “Show each message” opens the
step-through.
The step-through diagram needs JavaScript.
Your turn
Now you are the network. Deliver or drop each message, and reach the goal of each exercise.
paros-consensus runs in this page and decides everything else. “Deliver all” delivers every
message on the wire, and the messages they send, until the wire is empty.
The exercises need JavaScript.
The rule
A new leader proposes again every value that its Phase 1 reports, and it fills a slot with no reported value with a no-op. So a value that a dead leader got chosen stays in its slot, and the log has no hole. The run “What if a slot is lost with the leader?” shows the no-op. The run “Break the rule” shows a node that sends Accepts with no Phase 1: it never hears of the chosen value, and two values are chosen for one slot.
In paros
paros-consensus: the roles inproposer/,acceptor/andreplica/, andColocatedNodethat runs them together.- Each batch of work is persist, then send, then learn (
ReadyandHardStateincrates/lib/paros-consensus/src/lib.rs). - A heartbeat keeps the leader. A follower that misses it starts an election. The heartbeat
carries how far the log is chosen, so a lost
Commitis never sent again: the follower asks for the slots it lacks. - A leader can hand its ballot to a successor with no Phase 1 (
relinquish_to). A lost handoff costs an election, never a value. - paros has no leases, no commit index on an
Accept, no snapshot and no pre-vote. A read never goes through the leader. - Every node applies the chosen slots in order, so a
Write, aTruncateor aSetLeadergets the same answer on every node. - Consensus: the driver loop lets you drive three nodes (persist, then send, then learn), and the deployments show
ColocatedNode.