Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three phase commit

I understand that three phase commit was made to solve the problem of "two phase commit" when in the second phase the coordinator and the cohort fails at the same time it is impossible to know if the coordinator had decided on a commit message.

Apparently three phase commit aims to solve this problem by adding an extra phase. But don't you face the exact same problem during the third phase, if the coordinator and a cohort fails?

like image 704
Ken Avatar asked Jun 26 '12 14:06

Ken


People also ask

What is the purpose of three-phase commit?

Three-phase commit (3PC) is a synchronization protocol that ensures global atomicity of distributed transactions while alleviating the blocking aspect of 2PC (Two-Phase Commit) in the events of site failures. That is, 3PC never requires operational sites to wait (i.e., block) until a failed site has recovered.

How does a three-phase commit protocol work?

Three-Phase Commit (3PC) Protocol is an extension of the Two-Phase Commit (2PC) Protocol that avoids blocking problem under certain assumptions. In particular, it is assumed that no network partition occurs, and not more than k sites fail, where we assume 'k' is predetermined number.

How many phases three-phase commit protocol has?

There are two important types of protocols used in consensus: two-phase commits (2PCs) and a three-phase commits. In each type there is is a coordinator that receives transactions and participants (also called cohorts) that commit to the transaction or abort it.


1 Answers

In 3PC it is possible to figure out failed coordinator decision by querying remaining active cohorts. If any active cohort is in pre-commit state- that means that all of them agreed to commit (otherwise coordinator would not have sent pre-commit). And we need to commit the rest of the cohorts because failed ones might have committed.

If none of the cohorts is in pre-commit state - we can assume that coordinator has not sent 'commit' to any cohort, so no side effects has taken place and we can abort.

Here's good explanation: http://the-paper-trail.org/blog/consensus-protocols-three-phase-commit/

like image 168
Sergey Zyuzin Avatar answered Oct 21 '22 11:10

Sergey Zyuzin