Atomic Commits
How to do atomic commits? Two-phase commit.
Two-phase commit
Two-phase commit has a single coordinator and multiple participants.
First phase:
- The coordinator sends a prepare request to each of the nodes, asking them whether they are able to commit.
- If all participants reply yes, the coordinator sends a commit request in phase 2 (writing this on disk), and the commit takes place.
- If the commit request fails or times out, the coordinator must retry forever until it succeeds.
- If any of the participants replies no, then the coordinator sends an abort request.
Problems with 2PC: If the coordinator fails after it has sent out prepare requests to everyone, the participants are kind of stuck — they can’t abort anymore, because they must wait to hear back from the coordinator whether the transaction was committed or aborted.
Created from: Raft & Paxos 202211231100
uid: 202211232128 tags: #distributed-systems #software-engineering