This set practises the acceptor’s two promises, the adoption rule, the difference between “accepted by a majority” and “chosen”, and the quorum-intersection proof.
Problem 1
Problem 8.1 (One acceptor, step by step).An acceptor starts with
promised = acceptedBallot = acceptedValue = nulland receives, in this order:Prepare(3),Accept(2, u),Prepare(2),Accept(3, w),Prepare(5),Accept(4, z),Prepare(6). Ballots are plain integers.
- After each message, give the acceptor’s three variables and its reply (Promise, Accepted or Nack, with arguments).
- At the end,
promisedandacceptedBallotdiffer. Explain in one sentence what each one guarantees to future proposers.
Solution
Step by step (state written as promised / acceptedBallot / acceptedValue):
Prepare(3):, so promise. State 3 / null / null. Reply Promise(3, null, null).Accept(2, u):, reject. State unchanged. Reply Nack(2, 3).Prepare(2):, reject. State unchanged. Reply Nack(2, 3).Accept(3, w):, accept. State 3 / 3 / w. Reply Accepted(3, w).Prepare(5):, promise. State 5 / 3 / w. Reply Promise(5, 3, w).Accept(4, z):, reject. State unchanged. Reply Nack(4, 5).Prepare(6):, promise. State 6 / 3 / w. Reply Promise(6, 3, w).
promised = 6guarantees that this acceptor will never again accept a proposal with a ballot below 6 (promise 1).acceptedBallot = 3, acceptedValue = wis the report of the past (promise 2): the highest-ballot proposal it has accepted, which the proposer of ballot 6 must take into account under the adoption rule.
Problem 2
Problem 8.2 (Which value must the proposer send?).There are
acceptors A to E. Proposer P runs ballot 7 for its client’s value . For each set of Promise replies below, say what P sends next (and with which value), or explain why it cannot send anything yet. Replies are written as (acceptor: accepted proposal).
- A: none, B: none, C: none.
- A: (3, u), B: none, C: (5, w).
- A: (5, w), B: (5, w), D: (6, z).
- A: (3, u), E: (4, u).
- A: (5, w), B: (5, z), C: none.
Solution
- Three replies form a majority of five, and nobody has accepted anything: case (a) of P2c. P sends
Accept(7, q)with its own value.- Majority reached. The largest reported ballot is 5, so P must send
Accept(7, w). The older vote (3, u) is irrelevant.- Majority reached. The largest reported ballot is 6, so P sends
Accept(7, z), even thoughwas reported twice. Frequency does not matter; only the highest accepted ballot does. - Only two replies: not a majority of five. P must wait for a third Promise (or time out and retry with a higher ballot). Sending
Accept(7, u)now could be unsafe: a value could already be chosen at ballot 5 or 6 by B, C, D, and P has no reply from them. (A and E cannot be part of such a majority: each reports a highest accepted ballot below 5, and having promised 7 it will not accept 5 or 6 later.)- This set of replies cannot occur. Ballot 5 belongs to one proposer, which issues it with a single value (one value per ballot), so no two acceptors can report (5, w) and (5, z) with
.
Problem 3
Problem 8.3 (Accepted by a majority, but not chosen).Five acceptors A to E. Proposer P1 owns ballot 1, P2 owns 2, P3 owns 3, P4 owns 4. The following happens, in this order.
- P1 completes Phase 1 for ballot 1 with {A, B, C} (nothing reported) and sends
Accept(1, x); only A receives it, and A accepts.- P2 completes Phase 1 for ballot 2 with {C, D, E} (nothing reported) and sends
Accept(2, y)to all; for now, only D receives it, and D accepts.- P3 sends
Prepare(3)to {A, B, C}; all three promise. A reports (1, x), B and C report nothing. P3 sendsAccept(3, x); B and C accept it, the message to A is lost.- P4 sends
Prepare(4)to {A, D, E}; all three promise. P4 sends an Accept, and A, D and E accept it.Answer:
- Is each step allowed by the algorithm? Check every Promise and every acceptance against the acceptor’s
promised.- Right after step 3, how many acceptors have accepted some proposal with value
? Is chosen at that moment? - Which value does P4 send in step 4, and is it chosen?
- Does this execution violate agreement? Which exam answer does it refute?
Solution
- Step 1: A, B, C promise 1 (fresh), A accepts
since . Step 2: C, D, E promise 2 ( their previous values: C had promised 1, D and E nothing); D accepts since . Step 3: A (promised 1), B (promised 1), C (promised 2) all have promised, so all promise 3. A reports its accepted ; C reports nothing because it never received Accept(2, y). The largest reported ballot is 1, so P3 must use: Accept(3, x)is correct. B and C accept since. Step 4: A (promised 3), D (promised 2), E (promised 2) all promise 4. Every step is legal. - Three acceptors have accepted value
: A at ballot 1, B and C at ballot 3. That is a majority of five, but is not chosen: no single proposal has a majority. has one vote (A) and has two votes (B, C). - P4’s replies: A reports
, D reports , E reports nothing. The largest reported ballot is 2, so P4 must send Accept(4, y). A, D and E accept it, sois chosen: is the decided value. - No violation:
was never chosen, so choosing contradicts nothing, and every learner that counts votes per ballot learns only . The execution refutes the answer “a value is chosen once a majority of acceptors have accepted it”. A learner that counted votes per value would have learned after step 3, and agreement would then be broken.
Problem 4
Problem 8.4 (Reading the past from acceptor state).Three acceptors are in this state (the history before is unknown, but the algorithm was followed):
A: promised 4, accepted (3, y);
B: promised 4, accepted (1, x);
C: promised 2, accepted (2, z).
- For each of
, , , decide whether it can already have been chosen. Justify using the algorithm’s invariants and Theorem 8.8. - A proposer runs ballot 5. Which value must it send if its Phase-1 quorum is {B, C}? {A, B}? {A, C}?
- The three answers to part 2 are not all equal. Explain why this does not contradict agreement.
Solution
Recall two facts from Lemma 8.6. First, an acceptor’s accepted ballots never decrease, so its current
acceptedBallotis the largest it ever accepted. Second, proposals, , were all issued (they were accepted).
- Assume
, , are distinct, and suppose some proposal is chosen. If : the issued proposal has a higher ballot, so Theorem 8.8 gives . If moreover , the issued gives , a contradiction; and if , one value per ballot forces (ballot 2 was issued with ), again contradicting . If : a majority, i.e. two acceptors, must have accepted ballot . But B’s and C’s largest accepted ballots are 1 and 2, so only A ever accepted a ballot of 3 or more. So no proposal is chosen: neither , nor , nor has been chosen yet. (In particular cannot be chosen even if A or C accepted it long ago, because was issued afterwards with another value.) - Quorum {B, C}: reports
and , largest ballot 2, send . Quorum {A, B}: and , send . Quorum {A, C}: and , send . - Agreement constrains only chosen values, and nothing is chosen yet, so the future is still open. The adoption rule only guarantees that if a value had been chosen, every quorum would see it (a chosen value lives on a majority, which meets every Phase-1 quorum). Different quorums may see different unchosen votes, and whichever ballot 5 then gets accepted by a majority becomes the single chosen value.
Problem 5
Problem 8.5 (Only Phase-1 and Phase-2 quorums need to meet).Generalize Paxos: fix a family
of Phase-1 quorums and a family of Phase-2 quorums (sets of acceptors) such that every intersects every . A proposer waits for Promises from some and applies the adoption rule to those replies; a proposal is chosen when every acceptor of some accepted it. Everything else is unchanged.
- Prove: if
is chosen, every issued proposal with has . - With
acceptors, let be all sets of 3 acceptors and all sets of 2. Check the intersection condition. Do two Phase-2 quorums always intersect? Why is that not needed? - What is gained and what is lost compared with majorities for both phases when
?
Solution
- Repeat the proof of Theorem 8.8 with the new quorums; only the intersection step changes. Let
be the set that accepted . Strong induction on : let be issued, with Phase-1 quorum . The argument of Lemma 8.6 did not use the size of , so P2c holds for . By assumption ; an acceptor in it accepted with , so case (b) of P2c applies: is the value of the highest-ballot proposal accepted below by members of , and . If , one value per ballot gives . If , was issued and the induction hypothesis gives . So . - A 3-set and a 2-set of 4 acceptors have
elements in total, so they share an acceptor: the condition holds. Two 2-sets need not intersect ({A, B} and {C, D}). That is not needed: two proposals chosen at the same ballot have the same value by one value per ballot, and for different ballots the proof above only intersects the later ballot’s Phase-1 quorum with the earlier ballot’s Phase-2 quorum. - Gain: Phase 2, which runs once per value (and per command in Multi-Paxos), needs only 2 replies instead of 3, so it is faster and tolerates 2 slow or crashed acceptors. Loss: Phase 1 needs 3 of 4, so a new proposer can take over only while at most one acceptor is down. This observation is known as Flexible Paxos (1); it matters in practice because Phase 1 is rare once a stable leader exists (Module 9).