Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues...
Transcript of Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues...
![Page 1: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/1.jpg)
Two-phase commit
![Page 2: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/2.jpg)
Setting
Atomic update to data stored in multiple locations
Ex: Multikey update to a sharded key-value store
Ex: Bank transfer
Ex: Calendar update for multi-person meeting
Data stores can fail (temporarily), or operation can fail
![Page 3: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/3.jpg)
Implications of Two Generals
Cannot get agreement in a distributed system to perform some action at the same time.
Perform group of operations at some logical instant in time, not physical instant
- linearizable: after request start, before request end
![Page 4: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/4.jpg)
Goals
Atomicity: all changes or none
Linearizability: multi-key operation appears to happen at some logical instant in time, consistent with real time
Availability: (next time)
Fast reads: (Spanner)
![Page 5: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/5.jpg)
One Phase Commit?
Central coordinator decides, tells everyone else
What if some participants can’t do the request?
- Bank account has zero balance
- Bank account doesn’t exist, …
What if we want more throughput?
- Multiple coordinators can’t decide unilaterally
- What if concurrent operations conflict?
![Page 6: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/6.jpg)
Locks?
How do we get linearizability with multiple coordinators?
- Need to apply changes at same logical point in time
- Need all other changes to appear before/after
Acquire read/write lock on each location
What if some lock is busy?
- Wait? Could get into deadlock
- Give up and retry? Might fail again
![Page 7: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/7.jpg)
Two Phase Commit
Central coordinator asks
- May be many coordinators, one per transaction
Participants commit to commit
- Acquire any locks
- In the meantime no other ops allowed on that key
- Delay other concurrent 2PC operations
Central coordinator decides, tells everyone else
- Release locks
![Page 8: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/8.jpg)
Looks Like Caching with Leases?
Acquire shared/exclusive access to data
Perform ops to local data
Write result back to storage layer
What if servers can fail?
What if no node is trusted with data
- ex: transfer between two banks
![Page 9: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/9.jpg)
Calendar event creation
Doug has three advisors (Tom, Zach, Mike)
Want to schedule a meeting with all of them
- Let’s try Tues at 11, people are usually free then
Calendars all live on different nodes!
Other students also trying to schedule meetings
Nodes can fail, messages can be dropped (of course)
![Page 10: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/10.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
![Page 11: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/11.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
Meet at 11 on Tues
![Page 12: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/12.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
OK
![Page 13: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/13.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
Meeting Doug @ 11 on Tues
![Page 14: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/14.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
Meet at 11 on Tues
Meeting Doug @ 11 on Tues
![Page 15: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/15.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
OK
Meeting Doug @ 11 on Tues
![Page 16: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/16.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
Meeting Doug @ 11 on Tues
Meeting Doug @ 11 on Tues
![Page 17: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/17.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
Meet at 11 on Tues
Meeting Doug @ 11 on Tues
Meeting Doug @ 11 on Tues
![Page 18: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/18.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
Busy!
Meeting Doug @ 11 on Tues
Meeting Doug @ 11 on Tues
![Page 19: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/19.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
Meeting Doug @ 11 on Tues
Meeting Doug @ 11 on Tues
![Page 20: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/20.jpg)
Calendar event creation (wrong)
Tom Mike Zach
Doug
Meeting Doug @ 11 on Tues
Meeting Doug @ 11 on Tues
![Page 21: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/21.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
![Page 22: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/22.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Meet at 11 on Tues
![Page 23: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/23.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
OK
![Page 24: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/24.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues
![Page 25: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/25.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues
Meet at 11 on Tues
![Page 26: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/26.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues OK
![Page 27: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/27.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues
Maybe Meeting Doug @ 11 on Tues
![Page 28: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/28.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues
Maybe Meeting Doug @ 11 on Tues
Meet at 11 on Tues
![Page 29: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/29.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues
Maybe Meeting Doug @ 11 on Tues
Busy!
![Page 30: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/30.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues
Maybe Meeting Doug @ 11 on Tues
![Page 31: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/31.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues
Maybe Meeting Doug @ 11 on Tues
Never mind!
![Page 32: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/32.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues
![Page 33: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/33.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
Maybe Meeting Doug @ 11 on Tues
Never mind!
![Page 34: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/34.jpg)
Calendar event creation (better)
Tom Mike Zach
Doug
![Page 35: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/35.jpg)
Two-phase commit
Atomic commit protocol (ACP)
- Every node arrives at the same decision
- Once a node decides, it never changes
- Transaction committed only if all nodes vote Yes
- In normal operation, if all processes vote Yes the transaction is committed
- If all failures are eventually repaired, the transaction is eventually either committed or aborted
![Page 36: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/36.jpg)
Two-phase commitRoles:
- Participants (Mike, Tom, Zach): nodes that must update data relevant to the transaction
- Coordinator (Doug): node responsible for executing the protocol (might also be a participant)
Messages:
- PREPARE: Can you commit this transaction?
- COMMIT: Commit this transaction
- ABORT: Abort this transaction
![Page 37: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/37.jpg)
2PC without failuresCoordinator Participant Participant
PreparePrepare
Yes
YesCommit
Commit
Yes
![Page 38: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/38.jpg)
2PC without failuresCoordinator Participant Participant
PreparePrepare
Yes
NOABORT
ABORT
Nope
![Page 39: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/39.jpg)
Failures
In the absence of failures, 2PC is pretty simple!
When can interesting failures happen?
- Participant failures?
- Coordinator failures?
- Message drops?
![Page 40: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/40.jpg)
Participant failures: Before sending response?
Coordinator Participant ParticipantPrepare
Prepare
Yes
No Abort
Abort
Decision?
![Page 41: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/41.jpg)
Participant failures: After sending vote?
Coordinator Participant ParticipantPrepare
Prepare
Yes
YesCommit
Commit
Yes
![Page 42: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/42.jpg)
Participant failures: Lost vote?
Coordinator Participant ParticipantPrepare
Prepare
YesYes
No Abort
Abort
Decision?
![Page 43: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/43.jpg)
Coodinator failures: Before sending prepare
Coordinator Participant Participant
PreparePrepare
YesYes
Yes CommitCommit
![Page 44: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/44.jpg)
Coordinator failures: After sending prepare
Coordinator Participant ParticipantPrepare
Prepare
Yes YesYes Commit
Commit
PreparePrepare
![Page 45: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/45.jpg)
Coordinator failures: After receiving votes
Coordinator Participant ParticipantPrepare
Prepare
Yes YesYes Commit
Commit
PreparePrepare
Yes Yes
![Page 46: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/46.jpg)
Coordinator failures: After sending decision
Coordinator Participant ParticipantPrepare
Prepare
YesCommit
Yes Yes
Commit
Decision?
![Page 47: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/47.jpg)
Do we need the coordinator?Coordinator Participant Participant
PreparePrepare
Yes
Commit
Commit
Yes Yes
Decision?
![Page 48: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/48.jpg)
Can the Participants Decide Amongst Themselves?
Coordinator Participant ParticipantPrepare
Prepare
Yes or
No?
Commit?
Decision?
Yes
Yes
![Page 49: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/49.jpg)
Can the Participants Decide Amongst Themselves?
• Yes, if the participants can know for certain that the coordinator has failed
• What if the coordinator is just slow?
• Participants decide to commit!
• Coordinator times out, declares abort!
![Page 50: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/50.jpg)
2PC is a blocking protocol
• A blocking protocol is one that cannot make progress if some of the participants are unavailable (either down or partitioned).
• It has fault-tolerance but not availability.
• This limitation is fundamental.
![Page 51: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/51.jpg)
Can We Make 2PC Non-Blocking?
• Paxos is non-blocking
• We can use Paxos to update individual keys
• Can we use Paxos to update multiple keys?
• If both are on the same shard, easy
• What if on different shards?
![Page 52: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/52.jpg)
State machine
Paxos
Lab 4
State machine
State machine
Paxos
State machine
Paxos
Paxos
Shard master
![Page 53: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/53.jpg)
State machine
Paxos
Lab 4
State machine
State machine
Paxos
State machine
Paxos
Paxos
Shard master
2PC
2PC
Coordinator
![Page 54: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/54.jpg)
State machine
Paxos
Lab 4
State machine
State machine
Paxos
State machine
Paxos
Paxos
Shard master
2PC
2PC
Coordinator
![Page 55: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/55.jpg)
2PC on PaxosCoordinator Participant Participant
PreparePrepare
Yes
YesCommit
Commit
Yes
Paxos
Paxos
Paxos
Paxos
Paxos: state machine replication of operation log
![Page 56: Two-phase commit · 2020-05-20 · Fast reads: (Spanner) One Phase Commit? ... - Let’s try Tues at 11, people are usually free then Calendars all live on different nodes! Other](https://reader034.fdocuments.net/reader034/viewer/2022043018/5f3ad3629bbd23066f6dcc84/html5/thumbnails/56.jpg)
Two Phase Commit on PaxosClient requests multi-key operation at coordinator
Coordinator logs request
- Paxos: available despite node failures
Coordinator sends prepare
Replicas decide to commit/abort, log result
- Paxos: available despite node failures
Coordinator collects replies, log result
- Paxos: available despite node failures
Coordinator sends commit/abort
Replicas record result
- Paxos: available despite node failures