How does three-phase commit avoid blocking?

前端 未结 4 654
爱一瞬间的悲伤
爱一瞬间的悲伤 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:40

    The thing that helped me understand the non-blocking property was to realize that after the first round of messages both protocols are in essentially the same state; all participants have agreed that they can commit and are waiting for confirmation to do so.

    Now, consider what a participant knows after it replied "ok to commit" in the first round.

    • 2PC: another participant may have already received a message to commit and committed or, alternatively, no participants may have done any commits. So if the participant doesn't hear anything it has no idea what the group decision was.
    • 3PC: the participant can be sure that no other participant has performed any commit actions. It's still safe to roll back the entire operation in the case of coordinator failure.

    Moving on, after the second round of messages and confirmations in 3PC we are guaranteed that all participants know that the group decision is to commit.

    This means that there is never a time in 3PC when a participant does a commit action that another participant is not anticipating.

提交回复
热议问题