Walk through the two phases of two-phase commit.
Sketch your own answer first, then compare it with the one below.
A strong answer
In the prepare phase, the coordinator sends a prepare request to every participant. Each participant makes its changes durable, keeps its locks, and replies yes or no. A yes is a promise: it will commit if told to, even after a crash.
In the commit phase, the coordinator writes its decision to its own log. Commit if every vote was yes, abort otherwise. It then sends the decision, and each participant applies it, releases its locks and acknowledges.
Two points to name. The yes vote is the point of no return for the participant. The decision is final once the coordinator has logged it.
Sources
- Philip A. Bernstein, Vassos Hadzilacos, Nathan Goodman (1987). Concurrency Control and Recovery in Database Systems.
- Jim Gray, Leslie Lamport (2006). Consensus on Transaction Commit.