Three-phase commit protocol: Difference between revisions

Content deleted Content added
Alter: journal. | You can use this tool yourself. Report bugs here. | via #UCB_Gadget
m Clarify language "a specific type of failure"
 
(18 intermediate revisions by 14 users not shown)
Line 1:
{{Short description|Distributed algorithm}}
In [[computer networking]] and distributed [[database]]s, the '''three-phase commit protocol''' ('''3PC''')<ref name=3PC>{{cite techreporttech report
| last = Skeen
| first = Dale
Line 6 ⟶ 7:
| institution = Department of Computer Science, Cornell University
| url = https://ecommons.cornell.edu/handle/1813/6323
}}</ref> is a [[distributed algorithm]] whichthat letsensures all nodes in a [[distributed system|system]] agree to [[Commit (data management)|commit]] or abort a [[database transaction|transaction]]. It isimproves a refinement ofupon the [[two-phase commit protocol]] (2PC) whichby iseliminating morethe resilientpossibility toof failuresindefinite blocking caused by a specific type of failure during the commit phase.
 
==Motivation==
Line 12 ⟶ 13:
 
The three-phase commit protocol eliminates this problem by introducing the Prepared to commit state. If the coordinator fails before sending preCommit messages, the cohort will unanimously agree that the operation was aborted. The coordinator will not send out a doCommit message until all cohort members have '''ACK'''ed that they are '''Prepared to commit'''. This eliminates the possibility that any cohort member actually completed the transaction before all cohort members were aware of the decision to do so (an ambiguity that necessitated indefinite blocking in the [[two-phase commit protocol]]).
 
==Solution==
 
The pre-commit phase introduced above helps the system to recover when a participant or both the coordinator and a participant failed during the commit phase. When the recovery coordinator takes over after the coordinator failed during a commit phase of [[two-phase commit]], the new pre-commit comes handy as follows: On querying participants, if it learns that some nodes are in commit phase then it assumes that the previous coordinator before crashing has made the decision to commit. Hence it can shepherd the protocol to commit. Similarly, if a participant says that it had not received a PrepareToCommit message, then the new coordinator can assume that the previous coordinator failed even before it completed the PrepareToCommit phase. Hence it can safely assume that no participant has committed the changes, and hence safely abort the transaction.
 
==Extensions==
Using Skeen's original three-phase commit protocol, it is possible that a quorum becomes connected without being able to make progress (this is not a deadlock situation; the system will still progress if the network partitioning is resolved). Keidar and Dolev's E3PC<ref name=E3PC>{{cite journal|last=Keidar|first=Idit|author1-link=Idit Keidar|author2=Danny Dolev |title=Increasing the Resilience of Distributed and Replicated Database Systems|journal= Journal of Computer and System Sciences|volume=57|issue=3|date=December 1998|pages=309–324|
url=httphttps://webeeiditkeidar.technion.ac.ilcom/wp-content/uploads/~idishfiles/Abstracts/jcss.html|doi=10.1006/jcss.1998.1566|doi-access=free}}</ref> refines Skeen's three-phase commit protocol and solves this problem in a way which *''always*'' allows a quorum to make progress.
 
==Disadvantages==
Three-phase commit assumes a network with bounded delay and nodes with bounded response times; In most practical systems with unbounded network delay and process pauses, it cannot guarantee atomicity. The other drawback of the protocol is it requires at least three round trips to complete, needing a minimum of three round trip times (RTTs). This is potentially a long latency to complete each transaction.
 
==References==
Line 25 ⟶ 30:
==See also==
*[[Two-phase commit protocol]]
*[[Paxos algorithm]]
 
[[Category:Transaction processing]]