Implement Two-Phase Commit
prepare votes, all-or-nothing commit
Challenge 3 of Coordination & ConsensusAdvanced~55 min
Make several databases agree to commit, or none of them do. Implement the classic atomic-commit protocol: participants vote in a prepare phase, a coordinator decides commit only if every vote is yes, and the decision is driven home in a second phase. Build the voting participant, the coordinator's all-or-nothing rule, the full protocol, and the abort path. The consensus behind distributed transactions in Postgres XA, MySQL, and sharded stores.