Two-phase Commit
Created on 2022-01-20T17:22:06-06:00
System for first requesting changes be staged on one or more storage depots and then flipping those changes to be live after the data is secured.
Requires write ahead, undo/redo logs, need to handle acknowledgements going stale (ex. network partitions or crashes.)
Stage transaction
- Coordinator sends query to commit to all affected parties
- Coordinator waits until all parties respond
- Parties perform their component (writing undo/redo and write ahead logs)
- Parties inform coordinator if writing succeeded
- If any party failed coordinator issues abort to everyone
Commit transaction
- Coordinator sends commit to all affected parties
- Parties make the transaction changes permanent
- Parties send completion notice to coordinator
Abort transaction
- Coordinator sends abort to all affected parties
- Parties dump the staged transaction
- Parties send completion notice to coordinator