Goal
After this module you can explain how Multi-Paxos turns single-decree Paxos into a replicated log with one round trip per command, write the pseudocode of the five PMMC processes, and, for every invariant R1-R5, A1-A5, C1-C2, say formally what it states and prove why it holds.
Module 8 agreed on one value. A replicated state machine (Module 4) needs agreement on a sequence of commands: slot 1 holds the first command, slot 2 the second, and every replica applies them in slot order. The obvious construction runs a separate single-decree Paxos instance per slot. It is correct but slow: two round trips per command, and constant fights between proposers.
Multi-Paxos removes the waste with one observation: Phase 1 does not depend on the slot. A leader runs Phase 1 once for a ballot, covering all slots at the same time, and then needs only Phase 2, one round trip, for each new command. The lecture (09.03) presents Multi-Paxos through the paper “Paxos Made Moderately Complex” (PMMC) by van Renesse and Altinbuken (1), which gives complete pseudocode and a list of invariants, one group per kind of process.
This module covers lectures 09.03, 10.01, 10.02 and 10.03 (Paxos parts 3 to 6). The instructor’s advice for the midterm (10.03): “if you remember nothing else but why each invariant holds, you will do very well.” The section on invariants is therefore the core of the module. We use the paper’s names throughout: slot_in, slot_out, WINDOW, ballot_num, accepted, proposals, decisions, and messages p1a, p1b, p2a, p2b, adopted, preempted, decision.
From one value to a log
How do we get a log out of single-decree Paxos, and what does it cost? Number the log positions
Done naively, each command costs two round trips (Prepare/Promise, then Accept/Accepted) plus the messages to learn the decision. Worse, every replica with a client request starts its own proposals, so proposers collide constantly (the dueling scenario of Module 8, now in every slot).
The fix rests on three observations.
- A promise is not about a slot. An acceptor that promises ballot
can promise it for all slots at once: “I will not accept anything below in any slot”. Its Promise reply then reports its accepted proposals for every slot. - One proposer at a time. If one process, the leader, makes all proposals, there is no dueling. A leader whose ballot was adopted by a majority can propose in any slot without another Phase 1.
- Two round trips are inherent, but not per command. Lecture 10.01 stresses that consensus needs two round trips: one to establish the ballot, one to get a value accepted under it. Multi-Paxos pays the first one once per leader change and the second one once per command.
| Paxos per slot | Multi-Paxos, stable leader | |
|---|---|---|
| Phase 1 | once per slot | once per ballot (leader change), all slots |
| Phase 2 | once per slot | once per slot |
| round trips per command | 2 | 1 |
| competing proposers | in every slot | only during leader changes |
Try it: the leader’s scout runs Phase 1 once; then step through several client requests. Each one gets its own commander and its own slot, and each needs exactly one p2a/p2b round trip. Watch the replicas apply the slots in order even when decisions arrive out of order.
The PMMC architecture
Who are the processes, and how many of each do we need? PMMC splits the work of a Multi-Paxos server into five kinds of processes (lecture 10.01; Table I and Fig. 3 of the paper). One machine typically runs a replica, a leader and an acceptor.
| Process | Role | Single-decree analogue (Module 8) |
|---|---|---|
| replica | receives client requests, proposes them for slots, applies decided commands in slot order | client-facing proposer plus learner |
| leader | owns ballots; spawns scouts and commanders | proposer |
| scout | runs Phase 1 for one ballot, all slots at once | Prepare/Promise |
| commander | runs Phase 2 for one (ballot, slot, command) | Accept/Accepted |
| acceptor | votes; the fault-tolerant memory | acceptor |
To tolerate
Definition 9.1 (Ballots, commands and pvalues).
- A ballot is a pair
of a round number and a leader id , ordered lexicographically as in Module 8; is smaller than every ballot. Only leader uses ballots . The lecture writes as ” . ”, e.g. 0.1 for leader 0, round 1 (10.02). - A command is a triple
: client , a client-chosen command id, and the operation. - A pvalue is a triple
: “command proposed for slot under ballot ”. It plays the role of a Module 8 proposal, now tagged with a slot. - A command
is chosen (decided) for slot if for some ballot a majority of acceptors have in their acceptedsets.
Lecture correction: one scout per ballot, one commander per slot
Lecture 10.01 says the leader spawns a scout “for each command it wants to put in the log”. In PMMC a leader spawns one scout per ballot; the scout’s Phase 1 covers all slots. It spawns one commander per (ballot, slot) pair, i.e. per command. That asymmetry is the whole point of Multi-Paxos: Phase 1 is rare, Phase 2 is per command.
The five processes in pseudocode
What does each process do on each message? The pseudocode below follows the paper’s Figs. 1 (replica), 4 (acceptor), 6 (commander and scout) and 7 (leader) line by line (1); we write L, sets with {} and pvalues as <b, s, c>. Every process handles one message at a time, atomically.
Acceptor
// Acceptor. ballot_num and accepted are its memory (on stable storage).
ballot_num := bottom // smaller than every ballot
accepted := {} // set of pvalues <b, s, c>, never shrinks
on receive p1a(scout, b):
if b > ballot_num:
ballot_num := b // adopt the higher ballot (the promise)
send p1b(self, ballot_num, accepted) to scout
on receive p2a(commander, <b, s, c>):
if b == ballot_num:
accepted := accepted + {<b, s, c>}
send p2b(self, ballot_num) to commander- One variable
ballot_numplays the role of Module 8’spromised. There is no separateacceptedBallot:acceptedkeeps every pvalue the acceptor ever accepted, for all slots. - The acceptor always answers with its current
ballot_num. The receiver compares it with its own ballot: equal means “yes”, larger means “you were preempted”. There is no explicit Nack. - A p2a is accepted only under the acceptor’s current ballot (
b == ballot_num); a p2a with a higher ballot is not accepted either, because its scout must have run first (lecture 10.02: “you have to match on the proposal number”).
Scout and commander
// Scout(L, acceptors, b): Phase 1 of ballot b, for all slots at once.
waitfor := acceptors; pvalues := {}
send p1a(self, b) to every acceptor
on receive p1b(a, b2, r):
if b2 == b:
pvalues := pvalues + r
waitfor := waitfor - {a}
if |waitfor| < |acceptors| / 2: // a majority has answered
send adopted(b, pvalues) to L
exit
else: // b2 > b: someone is ahead
send preempted(b2) to L
exit// Commander(L, acceptors, replicas, <b, s, c>): Phase 2 for one slot.
waitfor := acceptors
send p2a(self, <b, s, c>) to every acceptor
on receive p2b(a, b2):
if b2 == b:
waitfor := waitfor - {a} // a has accepted <b, s, c>
if |waitfor| < |acceptors| / 2:
send decision(s, c) to every replica
exit
else:
send preempted(b2) to L
exitThe test ballot_num in the same atomic step in which it compared it with
Leader
The leader needs one operation on sets of pvalues. Among the pvalues reported for a slot, it must keep the command with the highest ballot (the Module 8 adoption rule, slot by slot), and those adopted commands must override its own proposals.
Definition 9.2 (The pmax function and the update operator).For a set
of pvalues, For two sets
of (slot, command) pairs, the update keeps every pair of , and the pairs of whose slot does not appear in :
In words: proposals := proposals <| pmax(pvals) means: for every slot in which some acceptor of the scout’s majority reported a vote, forget the leader’s own proposal and use the highest-ballot reported command; keep the leader’s own proposals only for slots nobody reported.
// Leader L. proposals: set of <s, c>, at most one per slot.
ballot_num := (0, L); active := false; proposals := {}
spawn Scout(L, acceptors, ballot_num)
on receive propose(s, c): // from a replica
if proposals has no entry for slot s:
proposals := proposals + {<s, c>}
if active:
spawn Commander(L, acceptors, replicas, <ballot_num, s, c>)
on receive adopted(b, pvals) with b == ballot_num:
proposals := proposals <| pmax(pvals) // reported votes win
for each <s, c> in proposals:
spawn Commander(L, acceptors, replicas, <ballot_num, s, c>)
active := true
on receive preempted((r2, L2)):
if (r2, L2) > ballot_num:
active := false
ballot_num := (r2 + 1, L) // larger than the preempting one
spawn Scout(L, acceptors, ballot_num)| Line | Why it matters |
|---|---|
proposals has no entry for slot s | at most one command per slot per ballot (C1) |
commanders only while active | no Phase 2 under a ballot whose Phase 1 has not succeeded |
| `proposals < | pmax(pvals)` |
ballot_num := (r2 + 1, L) | the new ballot is larger than every ballot the leader has seen in a preemption |
Example 9.3 (One adoption step).Leader L2 has
proposals = {<2, c3>, <3, c4>}(requests it received while inactive). Its scout for ballotcollects from A1 the set and from A2 the set , with . Then (slot 2: ballot beats ), and L2 spawns three commanders under
: for in slot 1 (already decided, re-deciding it is harmless), for in slot 2 (its own is dropped: the replica that proposed will propose it again in another slot), and for its own in slot 3.
Replica
A replica keeps the application state, the client requests not yet proposed, its outstanding proposals (slot, command), and the decisions it has received. Two counters walk along the log (lecture 10.02 suggests reading them as “log tail” and “next to apply”):
slot_out: the next slot whose decision the replica will apply; all slots below it are applied.slot_in: the next slot the replica will consider for a new proposal.
// Replica. WINDOW: how far proposals may run ahead of applied slots.
state := initial_state; slot_in := 1; slot_out := 1
requests := {}; proposals := {}; decisions := {}
on receive request(c): // c = <client, cid, op>
requests := requests + {c}
propose()
on receive decision(s, c):
decisions := decisions + {<s, c>}
while decisions has an entry <slot_out, c1>:
if proposals has an entry <slot_out, c2>:
proposals := proposals - {<slot_out, c2>}
if c2 != c1: // our command lost this slot:
requests := requests + {c2} // propose it again later
perform(c1) // advances slot_out
propose()procedure propose():
while slot_in < slot_out + WINDOW and requests is not empty:
// a reconfiguration decided WINDOW slots ago takes effect here
if decisions has <slot_in - WINDOW, c> and isreconfig(c):
leaders := new leaders named in c.op
if decisions has no entry for slot_in:
c := any element of requests
requests := requests - {c}
proposals := proposals + {<slot_in, c>}
send propose(slot_in, c) to every leader in leaders
slot_in := slot_in + 1
procedure perform(c): // c = <client, cid, op>
if c is decided in some slot s < slot_out, or isreconfig(c):
slot_out := slot_out + 1 // duplicate or reconfig: no op
else:
(next, result) := c.op(state)
atomically: state := next; slot_out := slot_out + 1
send response(cid, result) to c.client- Decisions can arrive in any order;
slot_outadvances only through a gap-free prefix of decided slots. - The same client command can be decided in two slots (a replica re-proposes a command that lost a slot, and the first proposal wins elsewhere after all, or two replicas propose the same request).
performexecutes it only the first time; this is how PMMC gets at-most-once execution. proposeskips slots that are already decided, so a replica never wastes a proposal on them.
Lecture correction: slot_out can overtake slot_in
Lecture 10.02 says that
slot_outis always behindslot_in, since only proposed slots can be applied. That holds for the system as a whole but not for one replica’s counters: a replica with no pending requests does not moveslot_in, while decisions for commands proposed by other replicas advance itsslot_out. When a new request arrives, theproposeloop simply skips the already decided slots.
The invariants and why they hold
This is the core of the module. PMMC states its correctness as invariants grouped by process type: R1-R5 for replicas (Section 2.1 of the paper), A1-A5 for acceptors (Section 2.2), C1-C2 for commanders (Section 2.3). The statements below follow the paper. The paper argues for them briefly in prose (“Maintenance of Invariants” and the two cases in Section 2.4) and notes that C1 implies A4, C2 implies A5, and A5 gives R1. Our proofs spell these arguments out; the two lemmas marked “our lemma” are not in the paper and only package steps that the paper makes in prose. Read the statement, then cover the proof and try to reproduce it.
| Invariant | Short statement | Holds because of |
|---|---|---|
| A1 | ballot_num only increases | acceptor code |
| A2 | accept only under the current ballot_num | acceptor code |
| A3 | accepted never shrinks | acceptor code |
| C1 | at most one command per (ballot, slot) | ballot owner + leader code |
| A4 | acceptors agree per (ballot, slot) | C1 + A2 |
| C2 | later commanders reuse a chosen command | pmax rule + quorum intersection |
| A5 | later acceptances reuse a chosen command | C2 |
| R1 | one decided command per slot | C1 + C2 |
| R2, R3, R4, R5 | replica bookkeeping | replica code |
Throughout, “a commander for accepted” is the counterpart of “chosen”.
Acceptor invariants A1 to A3: read off the code
Theorem 9.4 (Invariant A1).An acceptor can only adopt strictly increasing ballot numbers. Formally, for every acceptor
, if then , and every change of ballot_numis to a strictly larger ballot.
Proof
The only assignment to
ballot_numis in the p1a handler, guarded by. So every change replaces the value by a strictly larger one.
Theorem 9.5 (Invariant A2).An acceptor
can only accept (add it to ) if at that moment.
Proof
The only assignment that adds to
acceptedis in the p2a handler, guarded by.
Theorem 9.6 (Invariant A3).Acceptor
cannot remove pvalues from : if then .
Proof
acceptedis only ever assignedaccepted + {...}. (The paper calls this an impractical restriction and relaxes it in Sections 4.1 and 4.2; see the section on stable storage below.)
From A1 and A2 we get a fact used twice below: every pvalue ballot_num when it was added and ballot_num never decreases afterwards.
Commander invariant C1 and acceptor invariant A4
Theorem 9.7 (Invariant C1).For any ballot
and slot , at most one command is selected and at most one commander for is spawned. Formally: and each such commander is spawned at most once.
Proof
The paper calls C1 “trivial to enforce” because each ballot has one leader, which spawns at most one commander per ballot and slot (Section 2.4). We check this against the code. Let
. Only leader spawns commanders, and always with its own ballot_num, which has the form; so only spawns commanders with ballot .
is in ballot during one contiguous period. ballot_numchanges only in the preempted handler, towith , hence and the new value is strictly larger. So never returns to an old ballot, and it receives at most one adopted for (one scout per ballot; adopted messages for other ballots do not match). During that period, at most one commander per slot.
activeis false when the period starts, so commanders with ballotare spawned either in the adopted handler (once per pair in proposals) or in the propose handler whileactive.proposalsholds at most one pair per slot: the propose handler addsonly if slot has no entry, and keeps at most one pair per slot provided and do. For this requires that the highest-ballot pvalues reported for a slot carry one command; those ballots are smaller than (Lemma 9.9 below), so this is A4 for smaller ballots, which holds by strong induction on (A4 at a ballot follows from C1 at that ballot, as shown next). Finally, the adopted handler spawns one commander per pair, and afterwards the propose handler spawns only for slots without an entry, adding the entry at the same time. So each slot gets at most one commander with ballot , with one command.
Theorem 9.8 (Invariant A4).For any ballot
and slot , all acceptors that accepted a pvalue for accepted the same command: if and then .
Proof
This is the paper’s argument that C1 implies A4. An acceptor adds
only on receiving a p2a carrying exactly that pvalue, and p2a messages are sent only by commanders for that pvalue. By C1 (Theorem 9.7) all commanders with ballot and slot carry the same command. Hence .
The leader rule and the Phase-1 snapshot
Two lemmas isolate what a scout tells the leader and what the leader does with it. Both are our lemmas, not in the paper: the paper makes the same points in prose in Section 2.4 (“acceptors only report pvalues that they accepted before adopting ballot_num”, and the use of pmax on adoption).
Lemma 9.9 (Phase-1 snapshot (our lemma, not in the paper)).Let a scout for ballot
send adopted , based on p1b replies from a majority . Then (i) every pvalue in has ballot less than , and (ii) if some ever accepts a pvalue with , then .
Proof
Take
and the moment at which it sent p1b(alpha, b', accepted). Since the reply carries, at . (ii) Suppose
accepts with at time . By A2, , so by A1, . By A3, the pvalue is still in at , so it is in the reply and in . (i) Every pvalue in
‘s reply has ballot at most (the fact after A3). Ballot itself is impossible: a pvalue with ballot can only come from a commander for , which is spawned only after the leader received adopted , which is sent only after all replies in were received, hence after .
Lemma 9.10 (Leader rule (our lemma, not in the paper)).If a commander for
is spawned, then the leader of had earlier received adopted from its scout, and if contains a pvalue for slot , then is the command of the pvalue with the largest ballot among the pvalues for slot in .
Proof
Commanders with ballot
are spawned only in the adopted handler for or in the propose handler while activeis true withballot_num; activebecomes true only in the adopted handler and is reset wheneverballot_numchanges. So adoptedcame first. In that handler, if has a pvalue for slot , then contains with the command of the highest-ballot pvalue for , and makes the entry for slot in proposals, overriding any own proposal. From then on, while the ballot stays, the entry for slot never changes (the propose handler ignores slots that already have an entry). So every commander for carries .
The key invariant C2
Theorem 9.11 (Invariant C2).Suppose that for each
among a majority of acceptors, . If and a commander is spawned for , then .
Proof
This is the theorem of Module 8 (Theorem 8.8), slot by slot, and it formalizes the inductive argument of Section 2.4 of the paper (its case 1 is our step 3, its case 2 our steps 4 to 6). Fix
, , and a majority whose members all have in accepted. Strong induction on; assume the claim for every ballot with , and let a commander for be spawned.
- By Lemma 9.10, the leader of
received adopted based on p1b replies of a majority . - Quorum intersection: some acceptor
is in . accepted with , so by Lemma 9.9 (ii) it is in . Hence has a pvalue for slot , and by the leader rule is the command of the pvalue with the largest ballot for slot . , because is a candidate; by Lemma 9.9 (i). - Case
: and are both accepted, so by A4 (Theorem 9.8). - Case
: was accepted, so a commander for it was spawned; by the induction hypothesis for , . So
.
Intuition
Exactly as in Module 8: a command accepted by a majority under ballot
is written on a majority of whiteboards; every later leader reads a majority (its scout) before it may write, and must copy the newest entry it finds for that slot. Multi-Paxos runs this argument independently in every slot, but with a single scout that reads all slots at once.
Theorem 9.12 (Invariant A5).Suppose that for each
among a majority of acceptors, . If and for some acceptor , then . In words: once a command is chosen for a slot, every acceptance in that slot at a higher ballot carries the same command (lecture 10.02: “once accepted, always accepted”). The paper stresses that A5 also reads backwards: if some acceptor has accepted and later a majority accepts with , then .
Proof
This is the paper’s argument that C2 implies A5.
added on a p2a, which only a commander for sends. By C2 (Theorem 9.11), .
The main theorem: R1
Theorem 9.13 (Invariant R1: one command per slot).No two different commands are decided for the same slot, at any replicas:
Proof
A replica adds
to decisionsonly on a decisionmessage, and only a commander sends one: a commander for some that received p2b from a majority . Each such sent its reply with ballot_numin the step that handled the p2a, so the guard held and accepted . Hence: every decided has a ballot such that a majority has in accepted.Let
and be decided, with ballots and and commanders for and . If , C1 (Theorem 9.7) gives . Otherwise, say : a majority has and a commander was spawned for , so C2 (Theorem 9.11) gives . (The paper phrases the second case through A5, in Section 2.3: the majority behind the later decision accepted , so A5 gives . Both routes rest on C2.)
Exam trap: "R1 says a command is decided only once"
R1 is per slot: a slot never gets two different commands. It does not say a command occupies only one slot. The same client command can be decided in slots 4 and 7 (for example after a replica re-proposed it), and both decisions are legal. Exactly-once execution comes from
perform, which skips a command already decided in an earlier slot, not from R1.
Replica invariants R2 to R5
Theorem 9.14 (Invariant R2).All slots below
slot_outare decided:.
Proof
Initially
slot_outand the claim is vacuous. slot_outchanges only inperform, by, and performis called only inside the loopwhile decisions has an entry <slot_out, c1>. So slotslot_outis decided at the moment it is passed, anddecisionsnever shrinks.
Theorem 9.15 (Invariant R3).For all replicas
, is the result of applying the commands to initial_statefor allup to slot_out, in order of slot number. (The paper leaves implicit whatperformmakes explicit: a command already decided in an earlier slot, and a reconfiguration command, leaves the state unchanged. “Up toslot_out” means slots.)
Proof
By induction on the number of
performcalls. Initiallystate = initial_stateandslot_out = 1. Each call handles exactly slotslot_out(with the decided command, unique by R1), either leaving stateunchanged (duplicate or reconfiguration) or replacing it byc.op(state), and incrementsslot_outin the same atomic step. Nothing else touchesstate.
Theorem 9.16 (Invariant R4).For every replica
, never decreases.
Proof
The only assignment is
slot_out := slot_out + 1inperform.
Theorem 9.17 (Invariant R5).A replica proposes commands only for slots for which it knows the configuration. Formally, for every replica
, every slot that proposes for satisfies, at the moment of proposing, hence at all times
. The PMMC paper writes R5 as
. That is correct when read as the guard that holds at the moment a proposal is made; as an invariant of the variables at all times it is false, because equality is reachable.
Proof
Proposed slots. The loop of
proposeproposes foronly when its guard holds, so every proposed slot satisfies at that moment, and slot_outonly grows afterwards (R4).The variables. Initially
. slot_inchanges only in the loop, by, and only in an iteration whose guard gave , so afterwards . slot_outonly grows (R4), which keeps the inequality. Equality is reachable: the loop stops exactly when(for example : propose for slot 1, then ), which is why the strict form holds only at the moment of proposing. Why this means “it knows the configuration” is the topic of the reconfiguration section.
Corollary 9.18 (Replicas agree).If two replicas have applied the same number of slots (
), they are in the same state, and every client response sent for a slot is the same at every replica.
Proof
By R2 both replicas have decisions for every slot below
slot_out; by R1 these are the same commands. By R3 each state is obtained by applying this same sequence (with the same skipping rule, which depends only on the sequence) to the same initial state, and operations are deterministic.
Liveness: preemption and failure detection
Safety holds in every execution. When does the log actually grow? A command is decided once one leader is active and its commanders reach a majority. Preemption is what stops that.
When a scout or commander receives a p1b or p2b with a ballot larger than its own, it reports preempted to its leader, which becomes passive and starts a scout with a larger ballot. Lecture 10.02 describes this as the leader “stepping down”; in the code above it steps down only to immediately compete again. Two leaders can therefore preempt each other forever: L1’s new scout invalidates L2’s commanders, whose new scout invalidates L1’s, and so on. This is the dueling-proposers livelock of Module 8 at the level of leaders; the paper’s Fig. 9 shows it with two leaders and three acceptors, and notes that it happens even if both leaders propose the same command. FLP says some such execution must exist for any algorithm (2).
PMMC therefore adds failure detection (1):
- Pinging. A leader that learns through a preempted message that a higher ballot is active does not start a scout with an even higher ballot at once. It monitors the leader of that ballot by pinging it regularly, waits as long as the pings are answered in time, and only then picks a higher ballot and starts a scout (Section 3 of the paper).
- Timing assumption. Pinging cannot tell a crashed leader from a slow one in a purely asynchronous system. The paper assumes that clock drift and message delivery-and-handling time are bounded, without knowing the bounds (partial synchrony). The timeout grows with the competing ballot number, so eventually the timeouts are long enough that some correct leader gets its proposals chosen.
- Adaptive timeouts. For performance the paper suggests a TCP-like AIMD scheme: each ballot has an initial timeout; when a ballot is preempted, the next ballot’s timeout is multiplied by a small factor larger than 1, and with each chosen proposal the timeout is decreased linearly. (The paper calls this “additive increase, multiplicative decrease”, but the rule it describes is the reverse: multiply on preemption, decrease linearly on success.)
- What progress needs. A majority of acceptors and at least one replica and one leader alive, reliable (or fair-loss with retransmission) links, and clients that retransmit until answered. A replica whose command loses a slot re-proposes it in a new slot, so every outstanding request is eventually decided in some slot, although a request can starve while new ones keep arriving.
Try it: let leader L2 start a scout with a higher ballot while L1 has a command accepted by only one acceptor. Watch L1’s slot-3 commander, whose delayed p2a reaches the acceptors after L2’s Phase 1, get preempted, and check that L2’s adopted set contains L1’s pvalue, so L2 re-proposes the same command in that slot.
Reconfiguration and the WINDOW
How do we change the leaders and acceptors without stopping? PMMC treats the configuration as part of the replicated state: a reconfiguration is an ordinary command, decided in some slot like any other; if it is decided in slot
Definition 9.19 (Configuration of a slot).The configuration of slot
is the set of processes that run the Synod protocol for slot : its leaders and its acceptors, but not the replicas. It is the initial configuration, updated by every reconfiguration command decided in a slot (in slot order). A replica only needs the leaders (each leader knows its acceptors), so it applies this rule in propose: on reachingslot_in, it installs the leaders named by a reconfiguration decided in slotslot_in - WINDOW. Each slot and each ballot belongs to exactly one configuration (Fig. 5 of the paper); replicas can be added at any time without a reconfiguration.
Why the delay? A replica that wants to propose for slot
Try it: set WINDOW to 3 (or another value) and step on: the scenario sends many requests while the p2a messages of slot 1 are held back, so that slot stays undecided. slot_in stops at slot_out + WINDOW; decide the missing slot and watch slot_out jump and slot_in move on. Then issue a reconfiguration and see in which slot the new leaders take over (the simulator’s configuration command changes only the leader set and keeps the same acceptors).
No-ops. Two situations leave slots that nobody fills. First, a leader may crash after a replica proposed to it; the slot stays undecided, and since slot_out advances only through a gap-free prefix, it blocks all later slots at every replica. A new leader fills it: either the slot appears in its scout’s pvalues and it re-proposes that command, or the replica, still holding the proposal, sends it to the new leaders; a leader can also propose a no-op command for a gap. Second, after a reconfiguration is decided, the new configuration is used only
What must be on stable storage
What survives a crash? The PMMC pseudocode assumes that crashed processes stay crashed, which is what the counts
- Acceptors:
ballot_numandaccepted. Every acceptor invariant is about the history of these two variables, and the snapshot lemma (the step “the acceptor inremembers”) relies on them. An acceptor that forgot them would break C2 exactly as in Module 8 (Example 8.12). They must be written to disk before the p1b or p2b reply is sent. - Leaders: never reuse a ballot. (Our argument; the paper does not discuss it.) C1 relies on “a leader is in ballot
during one contiguous period”. A leader that restarts with ballot_num = (0, L)can climb back to a ballotit already used: a preemption by with sets its ballot to . Acceptors still at then answer its new scout with ballot , so it is adopted again, and if the old commander’s pvalue for slot sits only at acceptors outside the new Phase-1 majority, the leader spawns a second commander for with a different command. It must persist its current round, or embed a fresh incarnation number in its ballots. Its proposalsandactiveneed not be persisted: a restarted leader runs a new scout and re-learns everything that matters from the acceptors. - Replicas: nothing for safety. A replica’s
decisionsare copies of facts stored in a majority of acceptors (or at other replicas). A restarted replica can fetch decisions or a state snapshot from another replica. R4 then holds per incarnation.
A3 says acceptors never forget a pvalue, so accepted grows without bound. The paper’s Section 4 makes the protocol practical (1). State reduction (Section 4.1): an acceptor keeps only its most recently accepted pvalue per slot, which by A1 and A2 is also its highest-ballot one, and returns only those in p1b. That is all pmax needs, even though it can overwrite the evidence that a command was chosen; C2 still forces later ballots to carry that command. Garbage collection (Section 4.2): replicas periodically report their slot_out; once a leader or acceptor learns that at least
Worked example: a leader change in the middle of a slot
This is the trace of Figure 9.4 with all state written out. Acceptors A1, A2, A3 (majority = 2), leaders L1 and L2, replicas R1 and R2, ballots
- L1 is active under
. Its scout had all three acceptors adopt ; all acceptedsets were empty. - Slot 1. R1 proposes
for slot 1; L1’s commander gets p2b from all three: decision . Every replica applies ; slot_out. - Slot 2, partly. R1 proposes
for slot 2; commander sends p2a, which reaches only A1 for now. A1: accepted. is not chosen (one acceptor). - L2 takes over. L2 suspects L1 and starts a scout with
. R2 had sent L2 the proposal while L2 was inactive. A1 and A2 adopt (A1 and A2: ballot_num) and reply: A1 with , A2 with . - Adoption.
and proposals. L2 spawns commanders and : L2 completes L1’s command , not its own . - L1 is preempted. The delayed p2a
reaches A2, whose ballot_numis: not accepted, reply p2b . L1’s commander sends preempted ; L1 sets active = false. With failure detection it now watches L2 instead of starting a scout withat once. - Decisions. L2’s commanders get majorities: decision
(a repeat, ignored by R2’s duplicate-free set) and decision . R2 had proposal ; slot 2 was decided , so R2 puts back into requestsand proposes it for slot 3.
Change step 4 so that L2’s scout hears from A2 and A3 instead. Then no reply mentions slot 2, L2 keeps its own
Exam trap: "the new leader may propose its own command in any slot"
After adoption the leader must re-propose, in every slot reported by its scout, the command with the highest ballot, even if it never heard of that command and even if it already has its own proposal for that slot. Only in slots that no acceptor of its Phase-1 majority reported may it use its own proposals. Skipping this is exactly the Module 8 no-adoption bug, and it breaks C2, A5 and R1.
Lecture correction: a decided slot cannot roll back
At the end of lecture 09.03 the subtitles say that after the commit point “you can roll back”. The surrounding explanation and the invariants say the opposite: once a majority accepted
, every later commander and acceptance in slot carries (C2, A5), and decided slots are never undone (R1, R4). Read it as “you cannot roll back”.
Multi-Paxos and Raft
Lecture 10.03 recommends understanding Raft first, then single-decree Paxos, then PMMC, and carrying the high-level picture across. Module 10 does this in detail; here is the map.
| Concept | Multi-Paxos (PMMC) | Raft |
|---|---|---|
| log position | slot | log index |
| leadership token | ballot (round, leader) | term |
| becoming leader | scout gets p1b from a majority | RequestVote from a majority |
| new leader catches up by | adopting the highest-ballot pvalue per slot | nothing to learn: the voting rule guarantees it already has every committed entry |
| one leader per | ballot (C1) | term (Theorem 5.10) |
| replication | one commander per slot | AppendEntries with prefix check |
| holes in the log | allowed, filled later or by no-ops | impossible: logs are prefix-consistent |
The deepest difference is in the catch-up row. A Paxos leader may be elected with an incomplete log and then reads the missing votes from a majority (the pmax rule, Lemma 9.10). A Raft leader is elected only if its log is already at least as up-to-date as a majority’s, which yields Leader Completeness (Theorem 7.4): it never needs to learn committed entries from followers. Both rest on the same fact: the election majority intersects every commit majority.
What breaks
- Acceptor majority lost. With
of acceptors down, no scout or commander can finish: the log stops growing (safely). - Lost acceptor or leader state on restart. Forgetting
acceptedorballot_num, or reusing a leader’s ballot, breaks C1 or C2 and hence R1 (see the stable-storage section).- Leader contention. Without failure detection and adaptive timeouts, leaders can preempt each other forever. Liveness needs partial synchrony; safety does not.
- Gaps. One undecided slot blocks execution of all later slots at every replica until a leader fills it (with the reported command or a no-op).
- Reconfiguration lag. A reconfiguration takes effect only WINDOW slots after its decision; a large WINDOW means more pipelining but slower membership changes.
- Byzantine faults. All invariants assume processes follow the code. A lying acceptor can hide a pvalue from a scout and break C2.
Why it matters
Multi-Paxos is how Paxos is used in practice: one Phase 1 per leadership change and one round trip per command, with the single-decree safety proof applied independently to each slot. PMMC makes every step explicit, so each guarantee can be traced to a few lines of code (A1-A3, R2-R5) or to a short proof (C1, C2, A5, R1). Module 10 uses this map to compare Multi-Paxos with Raft ballot by term, scout by election, and commander by AppendEntries, and to see why both implement total order broadcast.
Further reading
- van Renesse and Altinbuken, “Paxos Made Moderately Complex” (1): Section 2 has the pseudocode (Figs. 1, 4, 6, 7) and all invariants, Section 3 liveness and failure detection, Section 4 state reduction, garbage collection, disk state, colocation and read-only commands.
- Lamport, “Paxos Made Simple” (3), last section: the original sketch of running Paxos as a replicated state machine.
- Howard and Mortier (4): Raft and Multi-Paxos compared side by side.
- Schneider (5): the state machine approach that Multi-Paxos implements.
Homework
The problems for this module are in Homework 9.