paxos-simple-Copy.pdf (microsoft.com)
Problem
- Choosing a single value among all
- Proposers, Acceptors, Learners
Choosing a Value
- P1. An acceptor must accept the first proposal
- (Because what if there is only a single proposal)
- imply => Acceptors must be allowed to accept more
- (If not, what if no majority?)
- However, need to ensure all chosen proposals have the same value =>
- => introduce proposal number
- A value is chosen when a single proposal with that value has been accepted by a majority of the acceptors.
- P2. If a proposal with value v is chosen, then every higher-numbered proposal that is chosen has value v.
- Can be satisfied by
- P2a . If a proposal with value v is chosen, then every higher-numbered proposal accepted by any acceptor has value v.
- Can be satisfied by
- P2b . If a proposal with value v is chosen, then every higher-numbered proposal issued by any proposer has value v.
- Can be satisfied by
- P2c . For any v and n, if a proposal with value v and number n is issued, then there is a set S consisting of a majority of acceptors such that either ^9e1ee4
- (a) no acceptor in S has accepted any proposal numbered less than n, or ^42ee99
- (b) v is the value of the highest-numbered proposal among all proposals numbered less than n accepted by the acceptors in S. ^4130fe
- => Proposer need to highest-number proposal less than
- => Can’t predict future => request promise
The Algorithm
- Proposer choose a proposal number
and sendprepare
request to acceptors - Acceptors response with
- Promise: never accept a proposal less than
, and - The proposal with highest number less than n that accepted
- Promise: never accept a proposal less than
- If proposer receives responses from majority
- issue proposal with number
and , where is the highest-number proposal - if no proposals => any
- issue proposal with number
- Send
accept
requests to acceptors - Acceptors accept iff it has not responded to a
prepare
request greater than
Client Store
- Highest numbered
prepare
request - Highest numbered it has ever accepted
Learners
- Acceptors send accepted value to a set of learners
- Learners inform other learners
Multipaxos
- Solve Replicated State Machines
- Optimization
- Select Leader (highest id)
Prepare
for the entire log, eliminate mostprepare
- Return
noMoreAccepted
if no accepted for log after current (OK
in paper) - (Proposer skip
prepare
if every accepternoMoreAccepted
)
- Example
- Leader: 1-134, 138, 139
- Phase 1 for 135-137, 140-
- Leader run Paxos, find out 135, 140
- Servers execute 1-135
- Leader fill 136, 137 with noop
- Servers execute 138-140
- Add/removing servers
- Use log to manage changes
Appendix
P2c Prove
- Suppose some proposal with number
and value is chosen - And suppose P2c[[#^9e1ee4]] (Proposer only propose (v, n) if (a) or (b))
- Prove any proposal issued with number
also has value - Induction hypothesis: Suppose every proposal issued with a number in
…( − 1) has value - Base Case
- The statement hold when
- The statement hold when
- Inductive step
- *Suppose every proposal issued with a number in
…( − 1) has value - => Every acceptor in some majority set
accepted - => Every acceptor in C has accepted a proposal with number in
… - Because at least each of them has accepted a proposal with number
- => Every proposal with number in
… accepted by any acceptor has value - By following P2c, the next proposal
will have value - P2c(a) [[#^42ee99]] will not happen because a majority set
accepted - P2c(b) [[#^4130fe]] come into play and will propose
- If
holds, then holds - If
holds - => any proposal issued with number also has value
ds.algorithms - Paxos made simple, invariant P2c - Theoretical Computer Science Stack Exchange
Paxos lecture (Raft user study) - YouTube
- *Suppose every proposal issued with a number in
In class
Focus on input to Replicated State Machines
- Paxos
- High overheads
- Better for small amount of essential info
- Chain
- Used to agree on membership replication
- Basic
- single value
- Multi Paxos
- no clear definition
Single paxos
Components
- Proposers
- Acceptors
- Store chosen value
- Know chosen value (learner)
- Clients talk to proposers
Broken implementation
- Single acceptor
- single point of failure
- => Multiple acceptors & accept only first value
- Work if one fail
- Fail if more than 2 proposers => might not be majority
- => Accept every value
- Might accept multiple values => bad
- => Need to discover previous proposal
- Still might accept multiple values
- ![[attachments/Paxos Bad.png]]
- => Must order proposals, reject old ones
Basic Paxos
- Proposal Numbers
- Each proposal has a unique number
- Higher numbers take priority
- Simple approach
|round number|server id|
- Every server stores
maxRound
(largest round number it has seen so far)
- Each proposal has a unique number
- Two-phase approach
- Phase 1
Prepare
- Find out any chosen value
- Block older proposals that have not yet completed
- (acceptors promise not to accept older proposals)
- Phase 2
Accept
- Ask acceptors to accept a specific value
- Phase 1
- No Liveness guarantee
- Solution 1: Randomize delay before restarting
- Solution 2: Leader election (Multi paxos)