Goal

After this module you can run single-decree Paxos by hand, state its safety invariants formally, prove that at most one value is ever chosen, and explain why each rule (ballots, promises, the adoption rule, stable storage) is needed by giving the execution that breaks without it.

Raft (Module 5 to Module 7) first elects a leader and then lets that leader order everything. Paxos starts from a smaller question: how can a group of nodes agree on one value, when any node may propose, messages can be delayed or lost, and nodes can crash and restart? The answer is a two-phase protocol in which a proposer first asks a majority to remember a ballot number and to report what they already accepted, and only then asks them to accept a value.

Single-decree Paxos is the building block. Module 4 showed that a replicated state machine needs agreement on a sequence of commands. Running one Paxos instance per position of the log gives that sequence, and Module 9 makes it efficient. The same idea that carried Raft’s safety proof carries this one: two majorities always share a node, and that node remembers.

This module covers lectures 09.01 and 09.02 (Paxos parts 1 and 2), which follow Lamport’s “Paxos Made Simple” (1). The original paper is (2). Kleppmann’s notes mention Paxos only in passing, so the lecture and Lamport’s paper are the sources here. Lamport writes the proposal number as ; we write it as (for ballot), because is the number of nodes.

The problem and the roles

What exactly must the nodes achieve, and who does what? The lecture (09.01) lists four requirements. Three are safety properties and one is liveness.

Definition 8.1 (Single-value consensus).

A set of processes proposes values; each process may learn (decide) a value. An algorithm solves single-value consensus if

  1. Validity: only a value that some process proposed can be chosen.
  2. Agreement: at most one value is chosen, so no two processes learn different values.
  3. Integrity: a process learns a value only if that value has actually been chosen, and it learns at most one value.
  4. Termination: every correct process eventually learns a value.

Items 1-3 are safety (“nothing bad happens”). Item 4 is liveness (“something good eventually happens”).

Paxos guarantees items 1-3 in every execution: under any message delay, loss, duplication and reordering, and under crashes and restarts of any number of nodes (as long as nodes keep their stable storage). It does not guarantee termination. That is not a design flaw: the FLP result (3) shows that no deterministic algorithm can guarantee both safety and termination in an asynchronous system where even one process may crash. Paxos keeps safety unconditionally and gets termination only when the system behaves synchronously for long enough (see the liveness section below).

The lecture also stresses the client’s view (09.01): Paxos is abortable. A client sends a request and may never hear back, because the attempt was aborted somewhere inside the protocol. The client then retries. This is the same contract as in Raft, and it is how systems such as Chubby and ZooKeeper are used in practice: a small fault-tolerant store for metadata such as cluster membership or the identity of the current leader.

Paxos splits the work into three roles. A single machine may play all three; the roles are logical.

RoleWhat it doesLecture analogy (09.01)
proposerreceives a client request, drives the protocol for its valuea citizen at the podium proposing a law
acceptorvotes; together the acceptors are the fault-tolerant memorythe assembly that votes
learnerfinds out which value was chosen and tells othersthe scribes who record the law

The analogy is Lamport’s: a parliament on the Greek island of Paxos whose members wander in and out, yet whose decrees must never contradict each other.

client value v proposer P1 proposer P2 acceptor A acceptor B acceptor C learner L1 learner L2 request Prepare Accept Promise Prepare Accept Promise Accepted Accepted acceptors: the fault-tolerant memory
Figure 8.1. The three Paxos roles. Any proposer may run the protocol against the acceptors; a value is chosen when a majority of acceptors accept the same proposal, and learners find out by collecting Accepted messages.

Ballots and acceptor state

Several proposers may run at the same time, and an acceptor must be able to accept more than one proposal over time (otherwise a crashed proposer could leave the acceptors split forever). So proposals need numbers, and the numbers must be totally ordered and never shared between proposers.

Definition 8.2 (Ballot).

A ballot (proposal number) is a pair of a round number and a proposer id . Ballots are compared lexicographically:

Only proposer issues ballots of the form , and it never issues the same ballot twice. A proposal is a pair of a ballot and a value.

The order is total, so any two ballots are comparable, and it is a well-order (there is no infinite decreasing chain), which is what makes induction on ballots valid. The lecture writes ballots as “sequence number dot server id”, e.g. 100.1 and 100.2 (09.01); proposers do not coordinate their numbers, uniqueness comes from the id. In examples we write ballots as plain integers such as 5 and 7 and say which proposer owns each.

Definition 8.3 (Acceptor state).

Each acceptor keeps three variables on stable storage:

  • promised (): the highest ballot has promised in Phase 1, initially ;
  • acceptedBallot (): the ballot of the last proposal accepted, initially ;
  • acceptedValue (): the value of that proposal, initially .

Here is smaller than every ballot. A proposal is chosen if there is a majority of acceptors such that every has accepted (at some point in the execution). A value is chosen if some proposal is chosen.

Promised and accepted are different things: a promise is about the future (“I will not accept anything below ”), an acceptance is a vote for a specific value. An acceptor that promised ballot 7 may still hold an accepted proposal from ballot 5. Note also that “chosen” is defined by acceptance events: once a majority accepted , that proposal stays chosen even if some of those acceptors later accept higher ballots.

When an acceptor answers a Prepare for ballot , it makes two promises (lecture 09.02):

  1. Do not go back: it will never again accept a proposal with ballot smaller than .
  2. Report the past: it tells the proposer the highest-ballot proposal it has accepted so far (or that it accepted nothing).

The first promise freezes the past of every acceptor in the Phase-1 quorum below ; the second hands that frozen past to the proposer. Together they let the proposer pick a value that cannot conflict with anything chosen at a smaller ballot.

The algorithm

How does one ballot run? Two phases, each one round trip to a majority of acceptors.

  • Phase 1 (prepare/promise). The proposer picks a fresh ballot and sends Prepare(b). An acceptor with sets and replies Promise(b, b_acc, v_acc).
  • Phase 2 (accept/accepted). With promises from a majority, the proposer picks the value by the adoption rule below and sends Accept(b, v). An acceptor with accepts: it records and sends Accepted(b, v) to the proposer and the learners.
Definition 8.4 (Adoption rule).

Let the proposer of ballot hold Promise replies from a majority . If every reply reports , the proposer may use any value (its client’s). Otherwise it must use the value of the reply with the largest .

The adoption rule is the heart of Paxos. The lecture’s example (09.02): a proposer wants to set , but the Promise with the highest accepted ballot reports ; the proposer must send Accept(b, x=5). Its own request is not lost: it goes into a different instance of consensus (in Module 9, the next log slot).

// Proposer p. Persistent: round (highest round p has used).
// myValue: the value p's client asked for.
procedure runBallot():
    round := round + 1                 // write to stable storage first
    b := (round, p)
    send Prepare(b) to every acceptor
    wait for Promise(b, bAcc, vAcc) from a majority Q   // on timeout: retry
    if every reply in Q has bAcc = null:
        v := myValue                   // free choice
    else:
        v := vAcc of the reply in Q with the largest bAcc   // adoption rule
    send Accept(b, v) to every acceptor
    // v is chosen once a majority accepts (b, v); learners detect it
 
on receive Nack(b, bProm) for the current ballot b:
    round := max(round, bProm.round)   // jump past the competitor
    abandon b; after a random backoff, call runBallot()
// Acceptor a. promised, acceptedBallot, acceptedValue are on stable storage.
promised := null; acceptedBallot := null; acceptedValue := null
 
on receive Prepare(b) from p:
    if promised = null or b > promised:
        promised := b                              // persist, then reply
        send Promise(b, acceptedBallot, acceptedValue) to p
    else:
        send Nack(b, promised) to p                // optional: speeds up p
 
on receive Accept(b, v) from p:
    if promised = null or b >= promised:
        promised := b
        acceptedBallot := b; acceptedValue := v    // persist, then reply
        send Accepted(b, v) to p and to every learner
    else:
        send Nack(b, promised) to p                // optional
// Learner l.
voters := empty map from ballot to set of acceptors
on receive Accepted(b, v) from acceptor a:
    voters[b] := voters[b] + {a}
    if |voters[b]| >= floor(n/2) + 1:
        learn v          // a majority accepted the same proposal (b, v)

The lines that matter for safety:

LineWhy it is there
round := round + 1, persisteda ballot is used at most once, with one value, even across proposer crashes
b > promised in Preparepromise 1: after replying, the acceptor never accepts below
reply carries acceptedBallot, acceptedValuepromise 2: report the frozen past
adoption rule in the proposerthe new ballot carries any value that may already be chosen
b >= promised in Acceptan acceptor accepts unless it promised a higher ballot
persist before replyinga restarted acceptor must still honour its promises and report its votes
learner counts per ballot“chosen” needs a majority on the same proposal

Nack messages are not needed for safety; they let a proposer give up early instead of waiting for a timeout. The lecture calls Phase 2a “propose” (09.02); we use Lamport’s name Accept.

Try it: step through one ballot with one proposer and three acceptors. Watch promised change in Phase 1 and acceptedBallot/acceptedValue change only in Phase 2, and note the step at which the value becomes chosen (before any learner knows it).

Phase 1: prepare and promise Phase 2: accept and accepted P A B C Prepare(5) Promise(5, none) Accept(5, E) Accepted(5, E) a majority accepted the proposal (5, E): value E is chosen
Figure 8.2. The happy path of lecture 09.02: proposer P runs ballot 5 against acceptors A, B and C. Phase 1 collects promises (nobody has accepted anything yet), Phase 2 gets value E accepted by a majority.

Deriving the algorithm from its invariant

Why these rules and not others? Lamport derives the algorithm backwards from the safety goal by a chain of ever stronger invariants (1). Following the chain is the best way to remember the rules, because each rule appears exactly where a weaker invariant cannot be enforced locally.

Definition 8.5 (The invariant chain).

Ballots are as in Definition 8.2; “issued” means a proposer sent Accept(b, v).

  • P1. An acceptor must accept the first proposal it receives.
  • P1a. An acceptor accepts a proposal with ballot if and only if it has not promised a ballot greater than .
  • P2. If a proposal is chosen, then every chosen proposal with a higher ballot has value .
  • P2a. If is chosen, then every proposal with a higher ballot accepted by any acceptor has value .
  • P2b. If is chosen, then every proposal with a higher ballot issued by any proposer has value .
  • P2c. For every issued proposal there is a majority such that either (a) no acceptor in ever accepts a proposal with ballot less than , or (b) is the value of the highest-ballot proposal among all proposals with ballot less than ever accepted by acceptors in .

The chain runs P2c P2b P2a P2. P2b implies P2a because an acceptor only accepts issued proposals; P2a implies P2 because a chosen proposal is accepted by at least one acceptor. P1 is the liveness wish (with a single proposer, something must get accepted), and P1a is how P1 is reconciled with the promises. The work is in P2c P2b, which is the main theorem below. Here is why each step is forced:

  • P2 cannot be enforced by an acceptor: it does not know whether a value is chosen. So strengthen to P2a, a statement about what any acceptor accepts.
  • P2a conflicts with P1: an acceptor that slept through ballot must accept the first proposal it sees, even one with a higher ballot and a different value. So move the constraint to the proposer (P2b).
  • P2b talks about the future: a proposer must know that no different value is or will be chosen at a smaller ballot. Predicting the future is impossible, so the proposer instead controls it by extracting promise 1 from a majority, and reads the past by promise 2. That is P2c, and it is exactly Phase 1 plus the adoption rule.
Lemma 8.6 (The algorithm maintains P2c and P1a).

In every execution of the algorithm above, every issued proposal satisfies P2c with the majority whose Promise replies the proposer used. Moreover each acceptor satisfies at all times, and P1a holds.

Lemma 8.7 (One value per ballot).

For every ballot there is at most one value such that a proposal is issued.

The safety theorem

The main fact (lecture 09.02 calls it “the most important property in Paxos”): once a majority has accepted a value, every later ballot carries that value.

Theorem 8.8 (Chosen values are carried forward).

If a proposal is chosen, then every proposal with that is issued has . Formally, if a majority accepted , then

Q: majority that accepted (b, v) Q': majority that promised b' A B C D E C reports an accepted ballot of at least b, so the adopted ballot lies in [b, b')
Figure 8.3. The quorum-intersection step of the safety proof with five acceptors. The acceptor in both majorities forces the proposer of the later ballot into case (b) of P2c with a reported ballot of at least the chosen one.
Corollary 8.9 (Agreement).

At most one value is chosen: if and are both chosen, then .

Proposition 8.10 (Validity and integrity).

Every chosen value was proposed by some client, and a learner following the algorithm learns only a chosen value.

Exam trap: "a majority accepted value v, so v is chosen"

Chosen means a majority accepted the same proposal , i.e. the same ballot. A majority that accepted at different ballots does not lock : with five acceptors, can be accepted by A at ballot 1 and by B and C at ballot 3 (three acceptors in total), and yet a later ballot can legally choose a different value. Problem 8.3 builds this execution. The learner in the pseudocode counts votes per ballot for this reason.

Exam trap: "a majority of promises means my value wins"

Phase 1 succeeding guarantees nothing about Phase 2. Between the promises and the Accept, another proposer can run Phase 1 with a higher ballot, and the acceptors will then reject the Accept. Only a majority of acceptances of one proposal chooses a value.

Why each rule is needed

A rule earns its place when removing it produces a bad execution. Here are the two most important ones, each with acceptors A, B, C (majority = 2).

Example 8.11 (Without the adoption rule, two values are chosen).

Suppose proposers ignore Promise replies and always send their own value.

  1. P1 runs ballot 1 with value : Prepare(1) to A and B; both promise. Accept(1, x) to A and B; both accept. is chosen (majority {A, B}), and learner L1 learns .
  2. P2 runs ballot 2 with value : Prepare(2) to B and C. B replies Promise(2, 1, x), C replies Promise(2, none).
  3. P2 ignores B’s report and sends Accept(2, y) to B and C. Both have promised exactly 2, so both accept. is chosen (majority {B, C}), and learner L2 learns .

Agreement is violated: L1 and L2 learned different values. With the adoption rule, step 3 would send Accept(2, x): the largest reported is 1, with value .

The lecture motivates the adoption rule by saying that otherwise proposers keep overriding each other forever (09.02). That is a fair picture, but the precise failure is worse than non-termination.

Lecture correction: the adoption rule protects safety

Lecture 09.02 says that without adoption, “every proposer keeps proposing something and it gets superseded” without end. Endless superseding can happen with adoption too (that is the dueling-proposers livelock below). What the adoption rule prevents is a safety violation: two different values each accepted by a majority, as in Example 8.11. Also, the lecture says the proposer that adopted will “propose my original command one more time with a higher proposal number”. Not in the same instance: once is chosen, every later ballot of this instance carries (Theorem 8.8). The command goes into a new instance, i.e. the next log slot (Module 9).

Try it: toggle “skip adoption (unsafe)” on, then run the two ballots. The second proposer ignores the value reported in the Promise, and the learners end up with two different chosen values. Toggle it off and run again: the second ballot now carries the first value.

ballot 1: majority {A, B} accepted x ballot 2: majority {B, C} accepted y acceptor A (1, x) acceptor B (1, x) then (2, y) acceptor C (2, y) B reported (1, x) to ballot 2, which ignored it: agreement is violated
Figure 8.4. The bug of the no-adoption scenario. Acceptor B is in both majorities and reports the earlier vote, but a proposer that skips the adoption rule throws that report away.
Example 8.12 (Without stable storage, two values are chosen).

Suppose acceptor B keeps its state only in memory.

  1. P1 runs ballot 1 with ; A and B promise and accept . is chosen.
  2. B crashes and restarts with promised = acceptedBallot = acceptedValue = null.
  3. P2 runs ballot 2 with against {B, C}. Both report “nothing accepted”, so P2 may use . Both accept . is chosen.

The intersection of {A, B} and {B, C} is B, but B forgot. Quorum intersection only helps if the node in the intersection remembers; that is why every acceptor writes its state to disk before replying. Forgetting only promised is also fatal: an acceptor that promised ballot 2, crashed and forgot, could then accept an old Accept(1, ...) after reporting “nothing below 2” to P2, breaking the proof step “every proposal below that accepts was accepted before ”.

A proposer has stable state too: round. If a proposer restarted with round = 0 it could reuse a ballot it already used with a different value, breaking Lemma 8.7.

Learning the chosen value

How does anyone find out? A value is chosen at the moment the last acceptor of some majority accepts, and at that moment nobody knows it. Learners must collect evidence.

  • All acceptors to all learners. Each acceptor sends Accepted(b, v) to every learner. A learner that sees a majority for one ballot learns . Fast (one message delay after acceptance) but costs (number of acceptors) times (number of learners) messages.
  • Distinguished learner. Acceptors send Accepted to one learner (often the proposer), which tells the others once it has a majority. Fewer messages, one extra delay, and the distinguished learner is a single point of failure for learning (not for safety).
  • Lost messages. If Accepted messages are lost, a learner may never see a majority, even though a value is chosen. The fix is to run another ballot: by Theorem 8.8, it carries the chosen value, and its Accepted messages reveal it.

A proposer that receives a majority of Accepted(b, v) for its own ballot knows that is chosen and can answer its client. That is the commit point of the protocol.

Liveness: dueling proposers

Safety never depends on timing. Progress does. The lecture’s scenario (09.02) has two proposers, P1 owning ballot 5 and P2 owning ballot 7, and acceptors A, B, C.

Example 8.13 (Dueling proposers livelock).
  1. P1 sends Prepare(5); A, B promise 5.
  2. P2 sends Prepare(7); A, B, C promise 7.
  3. P1 has a majority of promises and sends Accept(5, x). Every acceptor has promised 7 > 5, so all reject.
  4. P1 retries with Prepare(9); a majority promises 9.
  5. P2 sends Accept(7, y); rejected everywhere (9 > 7). P2 retries with Prepare(11), which makes P1’s Accept(9, ...) fail, and so on.

Every step is legal, safety holds throughout (nothing is ever chosen, so nothing conflicts), and the run never terminates.

Try it: let the two proposers retry immediately and watch each Prepare make the other’s Accept fail. Then switch on randomized backoff: one proposer waits long enough for the other to finish both phases, and a value is chosen.

P1 P2 Prepare(5) ok Prepare(7) ok Accept(5) rejected Prepare(9) ok Accept(7) rejected Prepare(11) ok Accept(9) rejected time each Prepare preempts the other proposer's pending Accept
Figure 8.5. Dueling proposers from lecture 09.02, continued: P1 owns ballots 5, 9, 13 and P2 owns 7, 11, 15. Each successful Phase 1 invalidates the other proposer's Phase 2, so the run can go on forever without choosing a value.

This is no accident of the algorithm. By FLP (3), every deterministic consensus algorithm for an asynchronous system with one crash failure has executions that never decide; dueling proposers are Paxos’s version of those executions. The practical remedies all aim at “eventually only one proposer is active for long enough”:

  1. Randomized backoff. A proposer whose ballot fails waits a random time before retrying, like Raft’s randomized election timeout (lecture 09.02 draws exactly this parallel). With high probability one proposer completes both phases while the other waits.
  2. Distinguished proposer (leader). Elect one proposer, e.g. with timeouts; others forward client requests to it. Lamport notes that with a single proposer that can talk to a majority, Paxos terminates (1). Leader election itself needs timing assumptions, which is fine: a wrong leader choice can only slow Paxos down, never make it unsafe.
  3. Jump ahead. On a Nack carrying the competitor’s ballot, choose a round above it instead of incrementing by one, to stop wasting attempts.

In terms of timing models: Paxos is safe in the asynchronous model and live in the partially synchronous model, once message delays stay bounded and a single proposer runs uninterrupted.

Worked example: adopting a value, and losing one

The lecture’s adoption example (09.02), made concrete. Acceptors A, B, C; proposer P1 owns ballot 2, proposer P2 owns ballot 4.

  1. P1 runs ballot 2 for “x = 5”. All three promise 2. P1 sends Accept(2, x=5); A and B accept, the message to C is lost. is chosen (majority {A, B}), but no learner knows yet: suppose all Accepted messages are delayed.
  2. P2’s client wants “x = 10”. P2 sends Prepare(4); only B and C answer. B: Promise(4, 2, x=5). C: Promise(4, none). State now: A (promised 2, accepted (2, x=5)); B (promised 4, accepted (2, x=5)); C (promised 4, nothing accepted).
  3. Adoption rule: the largest reported ballot is 2, with “x = 5”. P2 sends Accept(4, x=5). B and C accept; is chosen too, with the same value, as Theorem 8.8 promises.
  4. P2 now knows “x = 5” is the decided value of this instance. It tells its client that the instance decided “x = 5” (or, in a log, retries “x = 10” in the next slot).

Try it: the proposer wants 10, but a majority has already accepted 5. Before you Step past the Promise that completes a majority, look at the Promise replies listed under “In flight” and find the one with the highest accepted ballot. At that step the proposer sends Accept, and the simulator shows which value it is forced to use.

acceptor A accepted (2, x=5) not in the quorum acceptor B accepted (2, x=5) acceptor C accepted: none proposer P2, ballot 4 wants x=10, sends x=5 Promise(4, 2, x=5) Promise(4, none) the highest accepted ballot in the quorum is 2, so P2 must propose x=5
Figure 8.6. The adopt-value scenario at the moment P2 picks its value: the Promise quorum is {B, C}, and the reply with the largest accepted ballot decides.

Now change step 1: P1’s Accept(2, x=5) reaches only A, then P1 crashes. A value accepted by a minority is not chosen, and two futures are both correct:

  • If P2’s Phase-1 quorum is {B, C}, both report nothing, and P2 is free to propose “x = 10”; if B and C accept, “x = 10” is chosen and A’s vote for “x = 5” is simply outvoted forever (A will accept if it ever receives it).
  • If P2’s quorum is {A, B}, A reports , and P2 must adopt it; “x = 5” is chosen.

Losing “x = 5” in the first future is fine. No client was told that “x = 5” succeeded (P1 never got a majority of Accepted), so the client’s retry rule covers it: Paxos is abortable consensus (09.01). What would not be fine is losing a value that a majority accepted, and the theorem rules that out.

Exam trap: "adopt the most common value" or "adopt your own value if you can"

The rule is the value of the highest accepted ballot among the Phase-1 replies, not the most frequent value and not the proposer’s preference. With five acceptors, a Phase-1 quorum of three could report from one acceptor and from the other two; the proposer must use “x = 5”. Majority voting over values would pick “x = 7”, which may conflict with a value chosen at ballot 2 by acceptors outside the quorum.

What breaks

  • No majority alive. With or more acceptors down, no ballot can complete Phase 1: Paxos stops (safely). It tolerates crashed acceptors only when .
  • Lost stable storage. An acceptor that restarts with empty state can break agreement (Example 8.12). Crash-recovery is supported only with durable promised, acceptedBallot, acceptedValue (and the proposer’s round).
  • Contention. Competing proposers can livelock forever (Example 8.13); termination needs partial synchrony and backoff or a leader.
  • Byzantine nodes. An acceptor that lies in its Promise (for example, hides an accepted value) defeats the adoption rule. Paxos assumes crash faults only.
  • One value only. A single instance decides one value forever. A log needs many instances, and running full Paxos per entry costs two round trips per command; Module 9 fixes this.

Why it matters

Single-decree Paxos isolates the core of every majority-based consensus protocol: a fresh ballot, a Phase-1 quorum that freezes and reports the past, and a Phase-2 quorum that records a value. The safety proof (quorum intersection plus “adopt the highest accepted ballot” plus induction on ballots) is the template for Module 9, where it is applied slot by slot in Multi-Paxos, and for Module 10, where the same structure reappears as Raft’s term-based election (Theorem 5.10) and Leader Completeness (Theorem 7.4). Systems such as Chubby run this protocol underneath their lock and metadata services.

Further reading

  • Lamport, “Paxos Made Simple” (1): the derivation P1 to P2c in four pages.
  • Lamport, “The Part-Time Parliament” (2): the original, with the Greek parliament story.
  • Fischer, Lynch, Paterson (3): why no algorithm can guarantee termination in the asynchronous model.
  • Howard and Mortier (4): a unified view of Paxos and Raft, and which quorums really need to intersect.

Homework

The problems for this module are in Homework 8.

1.
Lamport L. Paxos Made Simple. ACM SIGACT News. 2001;32(4):51–8.
2.
Lamport L. The Part-Time Parliament. ACM Transactions on Computer Systems. 1998;16(2):133–69.
3.
Fischer MJ, Lynch NA, Paterson MS. Impossibility of Distributed Consensus with One Faulty Process. Journal of the ACM. 1985;32(2):374–82.
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.