Skip to content
← Back to glossary

2相コミットメントTwo-Phase Commit

Learn in the textbookTransaction Fundamentals and Concurrency Control

DefinitionTwo-phase commit (2相コミットメント) is a procedure that carries out a commit in two stages, prepare and commit, so that a transaction spanning several databases is either committed as a whole or cancelled as a whole.

ExplanationIn phase 1 the coordinator (調整役) overseeing the whole transaction asks each database whether it is ready to commit, and each database brings its updates to a state where they can be committed at any moment before answering yes or no. Only if every answer is yes does it order a commit in phase 2, and if even one is no it tells all databases to roll back. This prevents a mismatch in which one site has committed while another has cancelled.

AnalogyIt is like a group purchase where everyone is charged at once only after every member confirms they can pay; if a single person cannot, nobody is charged.

Memory hookThe 相 in the Japanese name translates phase. Phase 1 asks and phase 2 decides, so pair each number with its action.

Related past-exam questions(1 question)