How does three-phase commit avoid blocking?

前端 未结 4 650
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 05:16

I am trying to understand how three-phase commit avoids blocking

Consider the following two failure scenarios:

Scenario 1: In phase 2 the coordinator sends preCo

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 05:36

    In the two-phase commit the coordinator sends a prepare message to all participants (nodes) and waits for their answers. The coordinator then sends their answers to all other sites. Every participant waits for these answers from the coordinator before committing to or aborting the transaction.

    The two-phase commit protocol also has limitations in that it is a blocking protocol. For example, participants will block resource processes while waiting for a message from the coordinator. If for any reason this fails, the participant will continue to wait and may never resolve its transaction. Therefore the resource could be blocked indefinitely. On the other hand, a coordinator will also block resources while waiting for replies from participants. In this case, a coordinator can also block in definitely if no acknowledgement is received from the participant.

    However, the three-phase protocol introduces a third phase called the pre-commit. The aim of this is to 'remove the uncertainty period for participants that have committed and are waiting for the global abort or commit message from the coordinator.

    When receiving a pre-commit message, participants know that all others have voted to commit. 
    If a pre-commit message has not been received the participant will abort and release any blocked resources. 
    

提交回复
热议问题