This is a great question about the Paxos consensus algorithm. Let me break down the prepare and promise phases, and explain the invariants that make them work.
Paxos Prepare and Promise Phases
First, let me explain what these phases are:
Prepare Phase:
- A proposer chooses a unique proposal number
n and sends a PREPARE request with this number to a majority of acceptors
- The proposer waits for responses from a majority of acceptors
Promise Phase:
- When an acceptor receives a PREPARE request with proposal number
n:
- If
n is greater than any proposal number it has previously seen, it responds with a PROMISE
- In the promise response, it includes:
- Any value it has previously ACCEPTED (along with the proposal number of that acceptance)
- A promise that it will not accept any proposal with a number less than
n
- If
n is less than or equal to a proposal number it has seen, it ignores/rejects the request
Why must the proposer choose a higher proposal number?
This is critical for safety and liveness. Here are the key reasons:
-
Preventing conflicting decisions: If multiple proposers are active, they need to distinguish their proposals. Higher proposal numbers take precedence, preventing two different values from being accepted by the same acceptor's previous promises.
-
Breaking deadlock/livelock: If proposer A sends a prepare request with number 1, and proposer B also sends with number 1 at the same time, they could keep interfering with each other. By choosing higher numbers, proposers ensure progress. Eventually, one proposer will have a higher number and will succeed.
-
Implementing the core invariant: Paxos relies on the invariant that if a value has been chosen, then any higher-numbered proposal must propose that same value. This requires that higher proposal numbers can actually override lower ones.
-
Ensuring proposals aren't ignored: An acceptor promises not to respond to proposals with numbers lower than what it has promised.
A proposer must select a proposal number exceeding any that acceptors have already promised to guarantee its prepare request receives acknowledgment.
Why must an acceptor return any previously accepted value in its promise?
This is the most subtle and critical part of Paxos. Consider this scenario: three acceptors exist where A1 and A2 previously accepted "V1" with proposal number 5, while A3 has accepted nothing. Now a new proposer arrives with a higher proposal number. If A3 were allowed to accept a different value without knowing about V1, the system could end up with conflicting values chosen across different acceptor majorities. By requiring acceptors to report what they've already accepted, the new proposer learns about V1 and must propose it instead, maintaining consistency across all possible majorities. value must be chosen. The mechanism relies on the fact that any two majorities overlap—when a proposer prepares a new round, at least one acceptor in the responding majority will have previously accepted the value, and that acceptor reports it. The proposer then must propose that same value, ensuring continuity.
This is the fundamental safety guarantee of Paxos: once a value achieves majority acceptance, no other value can be chosen in subsequent rounds. The overlapping majorities and mandatory reporting of prior acceptances create an unbreakable chain that preserves the chosen value forward. 2 could propose a different value V2, which A2 and A3 accept, meaning V2 becomes chosen even though V1 was previously accepted by a majority. This breaks the fundamental guarantee that once a value is chosen, it stays chosen.
The mechanism works because the overlap between majorities ensures at least one acceptor in each new round knows about previously chosen values. This prevents different values from being selected across rounds, which is essential for consensus. When multiple proposers compete, requiring acceptors to report their prior acceptances ensures they all converge on the same value rather than diverging.
Paxos Prepare and Promise Phases
Phase Overview
Prepare Phase:
- Proposer selects a unique proposal number
n and sends PREPARE(n) to a majority of acceptors
Promise Phase:
- Acceptor receives PREPARE(n). If
n is higher than any previous proposal number seen:
- Returns PROMISE containing:
- Any value it has previously accepted (with the proposal number)
- Pledge: "I won't accept proposals numbered < n"
- Otherwise: ignores the request
Why Higher Proposal Numbers Are Essential
1. Breaking Livelock Among Concurrent Proposers
Without increasing numbers:
Proposer A with n=1 sends PREPARE(1)
Proposer B with n=1 sends PREPARE(1) ← Both conflict indefinitely
With increasing numbers:
Proposer A uses n=2, Proposer B uses n=3
→ Proposer B succeeds; A backs off and retries with n=4
2. Implementing Precedence
Higher numbers override lower ones. This provides a globally ordered "timeline" where later proposers can supersede earlier ones, preventing deadlock while preserving safety.
3. Ensuring Responses
Acceptors ignore proposals with numbers ≤ their promised minimum. To be heard, a proposer must use a higher number than previously seen acceptors have promised.
Why Acceptors Must Return Previously Accepted Values
This is the critical safety mechanism of Paxos.
The Problem Without This:
Previous round: Value V₁ accepted by majority {A1, A2} with n=5
New proposer with n=6:
├─ Gets PROMISE from {A2, A3}
├─ A2 says nothing about V₁ (doesn't report it)
├─ Proposer proposes different value V₂
└─ Now V₂ might be chosen by {A2, A3}
Result: Different values "chosen" in different rounds ✗ VIOLATED CONSENSUS
The Solution:
Previous round: V₁ accepted by {A1, A2} with n=5
New proposer with n=6:
├─ Gets PROMISE from {A2, A3}
├─ A2 reports: "I previously accepted V₁ at n=5"
├─ A3 reports: "I haven't accepted anything"
├─ Proposer sees V₁ was accepted; must propose V₁ (not something else)
└─ V₁ is chosen again
Result: Same value persists ✓
Key Insight — The Majority Overlap Guarantee:
Any two majorities must overlap by at least one acceptor.
Majority in round 1: {A1, A2, A3, A4, A5} ∩ {set of 3+}
Majority in round 2: {A3, A6, A7, A8, A9} ∩ {set of 3+}
↑
Guaranteed overlap ensures history propagates
- If a value is accepted by a majority in round 1
- Any future round that consults a majority will fetch responses from at least one acceptor that knows about that value
- The proposer must re-propose that value
The Core Invariant
"If a value has been chosen, it will be chosen in all future rounds."
This invariant is maintained through the chain: higher proposal number → consult majority → majority overlaps with previous majority → learn previously accepted value → re-propose it
Without returning accepted values, this chain breaks, and safety is violated.