Three-phase commit protocol
Encyclopedia
In computer networking and database
Database
A database is an organized collection of data for one or more purposes, usually in digital form. The data are typically organized to model relevant aspects of reality , in a way that supports processes requiring this information...

s, the three-phase commit protocol (3PC) is a distributed algorithm which lets all nodes in a distributed system agree to commit
Commit
Commit as a noun can refer to:* A set of permanent changes in a database or software repository.* A parliamentary motion*Nicotine, by the trade name Commit...

 a transaction
Database transaction
A transaction comprises a unit of work performed within a database management system against a database, and treated in a coherent and reliable way independent of other transactions...

. Unlike the two-phase commit protocol
Two-phase commit protocol
In transaction processing, databases, and computer networking, the two-phase commit protocol is a type of atomic commitment protocol . It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort the transaction...

 (2PC) however, 3PC is non-blocking. Specifically, 3PC places an upper bound on the amount of time required before a transaction either commits or aborts
Abort (computing)
In a computer or data transmission system, to abort means to terminate, usually in a controlled manner, a processing activity because it is impossible or undesirable for the activity to proceed. Such an action may be accompanied by diagnostic information on the aborted process.In addition to being...

. This property ensures that if a given transaction is attempting to commit via 3PC and holds some resource locks
Lock (computer science)
In computer science, a lock is a synchronization mechanism for enforcing limits on access to a resource in an environment where there are many threads of execution. Locks are one way of enforcing concurrency control policies.-Types:...

, it will release the locks after the timeout.

3PC was originally described by Dale Skeen
Dale Skeen
Dale Skeen is the Chief Technology Officer and co-founder of Vitria Technology, Inc., which he founded in 1994 with Dr. JoMei Chang. He has more than 20 years experience in designing and implementing large-scale computing systems and has made technical advances in the areas of distributed computing...

 and Michael Stonebraker
Michael Stonebraker
Michael Ralph Stonebraker is a computer scientist specializing in database research.Through a series of academic prototypes and commercial startups, Stonebraker's research and products are central to many relational database systems on the market today...

 in their paper, “A Formal Model of Crash Recovery in a Distributed System”. In that work, they modeled 2PC as a system of non-deterministic finite state automata and proved that it is not resilient to a random single site failure. The basic observation is that in 2PC, while one site is in the “prepared to commit” state, the other may be in either the “commit” or the “abort” state. From this analysis, they developed 3PC to avoid such states and it is thus resilient to such failures.

Protocol Description

In describing the protocol, we use terminology similar to that used in the two-phase commit protocol
Two-phase commit protocol
In transaction processing, databases, and computer networking, the two-phase commit protocol is a type of atomic commitment protocol . It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort the transaction...

. Thus we have a single coordinator site leading the transaction and a set of one or more cohorts being directed by the coordinator.


Coordinator

  1. The coordinator receives a transaction request. If there is a failure at this point, the coordinator aborts the transaction (i.e. upon recovery, it will consider the transaction aborted). Otherwise, the coordinator sends a canCommit? message to the cohorts and moves to the waiting state.
  2. If there is a failure, timeout, or if the coordinator receives a No message in the waiting state, the coordinator aborts the transaction and sends an abort message to all cohorts. Otherwise the coordinator will receive Yes messages from all cohorts within the time window, so it sends preCommit messages to all cohorts and moves to the prepared state.
  3. If the coordinator succeeds in the prepared state, it will move to the commit state. However if the coordinator times out while waiting for an acknowledgement from a cohort, it will abort the transaction. In the case where all acknowledgements are received, the coordinator moves to the commit state as well.


Cohort

  1. The cohort receives a canCommit? message from the coordinator. If the cohort agrees it sends a Yes message to the coordinator and moves to the prepared state. Otherwise it sends a No message and aborts. If there is a failure, it moves to the abort state.
  2. In the prepared state, if the cohort receives an abort message from the coordinator, fails, or times out waiting for a commit, it aborts. If the cohort receives a preCommit message, it sends an ACK
    Acknowledgement (data networks)
    In data networking, an acknowledgment is a signal passed between communicating processes or computers to signify acknowledgment, or receipt of response, as part of a communications protocol...

    message back.

Motivation

A Two-phase commit protocol
Two-phase commit protocol
In transaction processing, databases, and computer networking, the two-phase commit protocol is a type of atomic commitment protocol . It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort the transaction...

 cannot dependably recover from a failure of both the coordinator and a cohort member during the Commit phase. If only the coordinator had failed, and no cohort members had received a commit message, it could safely be inferred that
no commit had happened. If, however, both the coordinator and a cohort member
failed, it is possible that the failed cohort member was the first to be notified, and had
actually done the commit. Even if a new coordinator is elected, it cannot
confidently proceed with the operation until it has received an agreement from
all cohort members ... and hence must block until all cohort members respond.

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 ACKed 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
Two-phase commit protocol
In transaction processing, databases, and computer networking, the two-phase commit protocol is a type of atomic commitment protocol . It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort the transaction...

).

Disadvantages

The main disadvantage to this algorithm is that it cannot recover in the event the network is segmented in any manner. The original 3PC algorithm assumes a fail-stop model, where processes fail by crashing and crashes can be
accurately detected, and does not work with network partitions or asynchronous communication.

Keidar and Dolev's E3PC algorithm eliminates this disadvantage.

See also

  • Two-phase commit protocol
    Two-phase commit protocol
    In transaction processing, databases, and computer networking, the two-phase commit protocol is a type of atomic commitment protocol . It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort the transaction...


  • Paxos commit, an alternative fault-tolerant commit algorithm based on the Paxos algorithm for n-process consensus.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK