How does three-phase commit avoid blocking?

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

    In scenario 1 :

    During recovery: All cohorts ,except A, will be in PRECOMMIT state. This tells the recovery node that all cohorts had voted for the commit and moved forward . So A and Coordinator should be in PRECOMMIT state. Since this is a non-final state the transaction is aborted .

    In scenario 2 :

    During recovery: All cohorts ,except A, will be in PRECOMMIT state. This tells the recovery node that all cohorts had voted for the commit and moved ahead .But since A received the doCommit message it is in COMMITTED state.Had a crash not happened the recovery would ask all cohorts to commit since at least one cohort has committed. Since a crash (A crashed) happened the recovery node sees no live cohort with the committed state and hence it deduces that no cohort got the doCommit message. Hence the transaction will be aborted and all cohorts will be asked to release resources.

    when A returns from the crash and begins recovery it will find that all the other cohorts aborted the transaction and it too will abort the transaction .


    (source: swturner at regal.csep.umflint.edu)

提交回复
热议问题