Two-Phase Commit
A way to ensure consistency in a distributed system
Two Phases
- Phase 1
- coordinator sends "prepare to commit" message
- subordinates make sure they can do that no matter what happens
- write the action to a Database Transaction Log to tolerate failures
- subordinates reply with "ready to commit" message
- Phase 2
- if all ready, send "commit"
- if anyone fails, send "abort"
Example
- Coordinator: update
- Coordinator: prepare to commit
- Subordinate: write to log
- Subordinate: say "ready"
- Coordinator: commit
See also
Sources