Section 9: Lab 4 Part 3
CSE 452 Winter 2022
Distributed Systems in a nutshell
Questions about Lab 4?
Goal of Lab 4 Part 3
Two-Phase Commit
Transactions
Transactions: The Normal / Happy Path from Coordinator’s perspective
Transactions: The Normal / Happy Path from Participant’s perspective
R2
R1
R3
R{1,2,3} are replica groups. Each is a set of ShardStoreServers, each with a Paxos subnode.
Client
keys={a}
keys={b,c}
keys={d,e}
R2
R1
R3
R{1,2,3} are replica groups. Each is a set of ShardStoreServers, each with a Paxos subnode.
Client
keys={a}
keys={b,c}
keys={d,e}
MultiGet(keys={b,d})
Client sends a request to the Coordinator. Coordinator is the max({replica group ids involved in this transaction}). In this case, R3 (for key=d) and R2 (key=b) are involved, max(3,2) = 3. So replica group 3 is coordinator.
R2
R1
R3
R{1,2,3} are replica groups. Each is a set of ShardStoreServers, each with a Paxos subnode.
Client
keys={a}
keys={b,c}
keys={d,e}
Coordinator sends Prepare messages to all participants in the transaction. Participant should lock keys involved in transaction.
Prepare(command=MultiGet(keys={b,d})
Prepare(command=MultiGet(keys={b,d})
R2
R1
R3
R{1,2,3} are replica groups. Each is a set of ShardStoreServers, each with a Paxos subnode.
Client
keys={a}
keys={b,c}
keys={d,e}
PrepareOK
PrepareOK
Each replica group responds with PrepareOK �(including the information on what it’s responding to and maybe some values depending on what command is being performed [read or swap])
R2
R1
R3
R{1,2,3} are replica groups. Each is a set of ShardStoreServers, each with a Paxos subnode.
Client
keys={a}
keys={b,c}
keys={d,e}
Commit
Commit
R2
R1
R3
R{1,2,3} are replica groups. Each is a set of ShardStoreServers, each with a Paxos subnode.
Client
keys={a}
keys={b,c}
keys={d,e}
CommitOK({b:...})
CommitOK({d: …})
R2
R1
R3
R{1,2,3} are replica groups. Each is a set of ShardStoreServers, each with a Paxos subnode.
Client
keys={a}
keys={b,c}
keys={d,e}
Reply({b: ..., d: ...})
Tips
Deadlock or cyclic waiting: the problem
G1
G2
G3
G4
keys={k1}
keys={k2}
keys={k3}
keys={k4}
Write(k4, k2, k1)
Write(k3, k2, k1)
Deadlock solution: abort (the 2PC way)
Deadlock solution: lock ordering (the 332 way)
Aborts
Potential Workflow for part 3
Tackling the entire two-phase commit process at once can be difficult, so one suggestion of what order to get things done is
Note: Sending to everyone (involved) would require getting AbortOks from everyone (involved) if an abort happens
Note: 3. is the bulk of the work because you need these messages and also timers to retry as necessary (for Prepares, Commits, Aborts) [can delay timers until unreliable tests]
Potential Workflow for part 3 [continued]