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 (slots) and run one independent Paxos instance per slot. The instance for slot decides which command is the -th one. Agreement per instance gives agreement per slot, and replicas that apply slots in order stay identical (lecture 09.02).

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.

  1. 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.
  2. 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.
  3. 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 slotMulti-Paxos, stable leader
Phase 1once per slotonce per ballot (leader change), all slots
Phase 2once per slotonce per slot
round trips per command21
competing proposersin every slotonly 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.

phase 1, once slot 1 slot 2 R L A1 A2 A3 adopted propose decision p1a / p1b p2a / p2b p2a / p2b
Figure 9.1. Steady state of Multi-Paxos with replica R, leader L and acceptors A1 to A3. The leader's scout runs Phase 1 once for its ballot; afterwards every new command costs one propose message, one p2a/p2b round trip of a commander, and one decision message.

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.

ProcessRoleSingle-decree analogue (Module 8)
replicareceives client requests, proposes them for slots, applies decided commands in slot orderclient-facing proposer plus learner
leaderowns ballots; spawns scouts and commandersproposer
scoutruns Phase 1 for one ballot, all slots at oncePrepare/Promise
commanderruns Phase 2 for one (ballot, slot, command)Accept/Accepted
acceptorvotes; the fault-tolerant memoryacceptor

To tolerate crash failures, PMMC uses replicas, leaders and acceptors (lecture 10.03). Replicas and leaders only need one survivor each to keep going. Acceptors need a majority alive, because two majorities must intersect: that is why there are more of them.

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 accepted sets.
client command request replica R1 replica R2 leader L1 scout phase 1 commander phase 2 leader L2 scout phase 1 commander phase 2 propose decision propose decision acceptor A1 acceptor A2 acceptor A3 p1a, p2a p1b, p2b p1a, p2a p1b, p2b f+1 replicas f+1 leaders 2f+1 acceptors
Figure 9.2. The PMMC processes for f = 1. Replicas send every request to every leader (only one arrow each is drawn); a leader's scout runs Phase 1 and its commanders run Phase 2 against the acceptors; commanders broadcast decisions to all replicas.

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 as 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_num plays the role of Module 8’s promised. There is no separate acceptedBallot: accepted keeps 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
        exit

The test means that more than half of the acceptors have answered positively, i.e. a majority. A p2b with really means “accepted”: the acceptor sends its 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: picks, for every slot that appears in , the command of the pvalue with the largest ballot; is ” overwritten by ”. So 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)
LineWhy it matters
proposals has no entry for slot sat most one command per slot per ballot (C1)
commanders only while activeno 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 ballot collects 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_out advances 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). perform executes it only the first time; this is how PMMC gets at-most-once execution.
  • propose skips 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_out is always behind slot_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 move slot_in, while decisions for commands proposed by other replicas advance its slot_out. When a new request arrives, the propose loop 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.

InvariantShort statementHolds because of
A1ballot_num only increasesacceptor code
A2accept only under the current ballot_numacceptor code
A3accepted never shrinksacceptor code
C1at most one command per (ballot, slot)ballot owner + leader code
A4acceptors agree per (ballot, slot)C1 + A2
C2later commanders reuse a chosen commandpmax rule + quorum intersection
A5later acceptances reuse a chosen commandC2
R1one decided command per slotC1 + C2
R2, R3, R4, R5replica bookkeepingreplica code
acceptor code A1, A2, A3 ballot has an owner leader code on adopted pmax rule replica code R2 to R5 lemma p1b snapshot one command each C1 and A4 later ballots C2 acceptor view A5 one per slot R1 replicas agree same state
Figure 9.3. Which invariant is used to prove which. An arrow from X to Y means that the proof of Y uses X. The two highlighted boxes are the heart of the safety argument.

Throughout, “a commander for is spawned” is the PMMC counterpart of “the proposal is issued” in Module 8, and “a majority has in 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_num is to a strictly larger ballot.

Theorem 9.5 (Invariant A2).

An acceptor can only accept (add it to ) if at that moment.

Theorem 9.6 (Invariant A3).

Acceptor cannot remove pvalues from : if then .

From A1 and A2 we get a fact used twice below: every pvalue in has , because equalled 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.

Theorem 9.8 (Invariant A4).

For any ballot and slot , all acceptors that accepted a pvalue for accepted the same command: if and then .

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 .

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 .

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 .

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 .

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:

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_out are decided: .

Theorem 9.15 (Invariant R3).

For all replicas , is the result of applying the commands to initial_state for all up to slot_out, in order of slot number. (The paper leaves implicit what perform makes explicit: a command already decided in an earlier slot, and a reconfiguration command, leaves the state unchanged. “Up to slot_out” means slots .)

Theorem 9.16 (Invariant R4).

For every replica , never decreases.

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.

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.

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.

L1 A1 A2 A3 L2 p2a(b1, 2, c2) p1a(b2) p1b: A1 reports <b1, 2, c2> p2a(b2, 2, c2) p2b, then decision(2, c2) rejected: ballot_num is b2 preempted(b2) new ballot (3, L1)
Figure 9.4. The preemption scenario with ballots b1 = (1, L1) and b2 = (2, L2). L1's command c2 for slot 2 reaches only A1; L2's scout reads A1 and A2, so pmax returns c2 for slot 2 and L2 re-proposes it. L1's delayed p2a meets A2 after A2 adopted b2, the p2b carries b2, and L1 is preempted.

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 , it does not take effect until slot (Section 2.1 of the paper; lecture 10.02).

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 reaching slot_in, it installs the leaders named by a reconfiguration decided in slot slot_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 must know the configuration of , i.e. every decision up to slot . By R5 (read at the moment of proposing), , so , and by R2 all those slots are decided and known locally. In the paper’s words, all decisions up to are known, so configurations up to slot are known. Without the delay (, configuration of fixed by slot ) a replica could propose only for the very next slot and wait for it to be decided first: no pipelining. With a larger , up to commands can be in flight at once, at the price that a reconfiguration takes effect only slots after it is decided. The lecture’s rationale: the leaders have commands in flight in the old configuration, and those should be completed in that configuration.

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).

applied proposed, some decided may propose blocked 1 c1 2 cfg 3 c3 4 ? 5 c5 6 ? 7 8 9 10 slot_out = 4 slot_in = 7 slot_out + WINDOW = 9 slot 2 holds a reconfiguration: it takes effect at slot 2 + WINDOW = 7
Figure 9.5. A replica's view of the log with WINDOW = 5. Slot 5 is decided but cannot be applied until slot 4 is; slots 7 and 8 may still receive proposals; slot 9 must wait until slot_out advances. The reconfiguration decided in slot 2 governs proposals from slot 7 on.

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 slots later; if there is little traffic, the leaders can propose no-ops to reach the boundary quickly (lecture 10.02: “it just puts no-ops until it hits the new configuration boundary”). A no-op is an ordinary command whose operation does not change the state, so it is safe by R1 like any other command.

What must be on stable storage

What survives a crash? The PMMC pseudocode assumes that crashed processes stay crashed, which is what the counts and are about. The paper notes that keeping state on disk improves liveness: a process that loses power but recovers from disk is “not theoretically considered crashed”, only slow for a while (Section 3). It recommends write-ahead logging for the disk state (Section 4.3) and leaves storing acceptor and leader state on stable storage as an exercise (Section 4.6, exercise 7). Lecture 10.02 asks which state must be durable; the proofs above tell us.

  • Acceptors: ballot_num and accepted. Every acceptor invariant is about the history of these two variables, and the snapshot lemma (the step “the acceptor in remembers”) 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 ballot it 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 proposals and active need 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 decisions are 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 replicas have all decisions up to slot , it can drop its state for lower slots. The acceptor then keeps a slot number below which everything was collected and includes it in p1b, so that a new leader does not mistake a collected slot for an empty one and propose there.

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 .

  1. L1 is active under . Its scout had all three acceptors adopt ; all accepted sets were empty.
  2. Slot 1. R1 proposes for slot 1; L1’s commander gets p2b from all three: decision. Every replica applies ; slot_out .
  3. Slot 2, partly. R1 proposes for slot 2; commander sends p2a, which reaches only A1 for now. A1: accepted . is not chosen (one acceptor).
  4. 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 .
  5. Adoption. and proposals . L2 spawns commanders and : L2 completes L1’s command , not its own .
  6. L1 is preempted. The delayed p2a reaches A2, whose ballot_num is : 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 with at once.
  7. 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 requests and 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 , and slot 2 is decided . Is lost? It was never decided (one acceptor only), so no client was answered; R1 sees slot 2 decided and re-proposes in a later slot. Both outcomes satisfy R1.

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.

ConceptMulti-Paxos (PMMC)Raft
log positionslotlog index
leadership tokenballot (round, leader)term
becoming leaderscout gets p1b from a majorityRequestVote from a majority
new leader catches up byadopting the highest-ballot pvalue per slotnothing to learn: the voting rule guarantees it already has every committed entry
one leader perballot (C1)term (Theorem 5.10)
replicationone commander per slotAppendEntries with prefix check
holes in the logallowed, filled later or by no-opsimpossible: 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 accepted or ballot_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.

1.
van Renesse R, Altinbuken D. Paxos Made Moderately Complex. ACM Computing Surveys. 2015;47(3):42:1-42:36.
2.
Fischer MJ, Lynch NA, Paterson MS. Impossibility of Distributed Consensus with One Faulty Process. Journal of the ACM. 1985;32(2):374–82.
3.
Lamport L. Paxos Made Simple. ACM SIGACT News. 2001;32(4):51–8.
4.
Howard H, Mortier R. Paxos vs Raft: Have We Reached Consensus on Distributed Consensus? In: Proceedings of the 7th Workshop on Principles and Practice of Consistency for Distributed Data (PaPoC). 2020.
5.
Schneider FB. Implementing Fault-Tolerant Services Using the State Machine Approach: A Tutorial. ACM Computing Surveys. 1990;22(4):299–319.