Distributed Introductory 4: two phase commit

Source: Internet
Author: User

1. Background: At the beginning, it is to solve the problem of distributed database transaction. Single-machine database transaction Reliable log technology, MVCC technology implementation. In a distributed situation, there is a need for additional means to ensure that there is a two-phase commit. 2. Process: From the role, the two-phase commit is divided into two roles: Coordinator (coordinate)participants (participant)。 The process of thinking is very simple:    1. The facilitator asks all participants if they can submit them, and the participants return the results;    2. The facilitator decides whether to commit the transaction based on the participant's return result and notifies the participant to execute.   But in fact, two-phase submissions need to take into account a number of unusual scenarios:    control: 1 Downtime class:    coordinator down: Get up and look at the local log.         If begin_commit, send prepare. Even if the participant has already sent a response, it does not affect. The process is normal.         Resend Global-commit or Global-abort if Global_commit or Global_abort. (If the participant has already submitted it, what to do).         If the facilitator does not come, start a new coordinator and take status to the participants. If there is a commit, continue the commit, otherwise abort.      Participant downtime: Get up and look at the local log.         If at Init, wait for prepare. If the coordinator has already sent it, it will time out, see below.         If you are in the Ready log, follow the process to send vote-commit to continue down.         If you are at abort or commit log, do nothing, wait for the coordinator to re-send.  2 Waiting for response timeout class     in general, a phase timeout exits the process directly, and the two-phase timeout continues to retry.     Coordinator Timeout:        Wait for participants to time out the prepare response (received all vote-commit, but still have unresponsive participants). At this time, directly give up, send Global_abort.         Wait for the response of Global-commit or Global-abort to time out. At this time, there is no other way, only constantly retry. This may cause the participant to repeat the submission.      Participant Timeout:    &NBsp   After Init, timeout at prepare wait. Go directly to abort. Even after receiving prepare, the process is still correct.         Confirm that it can be submitted and time out while waiting for the coordinator two-stage command. Instructions have been sent Vote_commit, because do not know the status of the process, can only continue to re-hair vote_commit. The    two phase protocol is less applied and the theoretical value is greater than the practical value.

Distributed Primer 4: Two-phase commit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.