In computer networking and databases, the two-phase-commit protocol is a distributed algorithm which lets all nodes in a distributed system agree to commit a transaction. The protocol results in either all nodes committing the transaction or aborting, even in the case of network failures or node failures. However, according to the work by Skeen and Stonebraker, the protocol will not handle more than one random site failure at a time. The two phases of the algorithm are the commit-request phase, in which the coordinator attempts to prepare all the cohorts, and the commit phase, in which the coordinator completes the transactions at all cohorts.
The protocol is initiated by the Coordinator after the last step of the transaction has been reached. The Cohorts then respond with an agreement message or an abort message depending on success.
Another disadvantage is the protocol is conservative. It is biased to the abort case rather than the complete case. Also it cannot recover from cases where a node has failed in the commit stage (due to internal or network failures) after indicating that it is ready to commit. In this case, resources that committed prior to this failure cannot be rolled back.
A lot of database research has been done on ways to get most of the benefits of the two-phase-commit protocol without the costs.
A common variant of 2PC in a distributed system is the Tree 2PC protocol. In this variant the coordinator is the root ("top") of a communication tree, while the cohorts are the other nodes. Messages from the coordinator are propagated "down" the tree, while messages to the coordinator are "collected" by a cohort from all the cohorts below it, before it sends the appropriate message "up" the tree (except an "abort" message, which is propagated "up" immediately upon receiving it, or if this cohort decided to abort).
The Dynamic two-phase-commit (Dynamic two-phase-commitment, D2PC) protocol is a variant of Tree 2PC with no predetermined coordinator. Agreement messages start to propagate from all the leaves, each leaf when completed its tasks on behalf of the transaction, and the coordinator is determined dynamically by racing agreement messages, at the place where they collide. They collide either on a transaction tree node, or on an edge. In the latter case one of the two edge's nodes is elected as a coordinator (any node). D2PC is time optimal (among all the instances of a specific transaction tree, and any specific Tree 2PC protocol implementation; all instances have the same tree; each instance has a different node as coordinator): It commits the coordinator and each cohort in minimum possible time, allowing earlier release of locked resources.
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Two-phase-commit protocol".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world