Transaction execution statuses

更新时间:
复制 MD 格式

Distributed transactions use the two-phase commit (2PC) protocol to ensure atomicity.

The 2PC protocol includes two phases:

  • Phase 1, the prepare phase. The transaction initiator sends a request to each participant to determine if they are ready to execute the transaction.

  • Phase 2, the commit phase. After all participants confirm in Phase 1 that they are ready, each participant executes its transaction branch. If all branches are executed successfully, the transactional data is committed. If any branch fails, the data in all branches is rolled back.

2PC

A transaction can be in one of the following states:

  • Initialization: The application initiates the transaction.

  • In progress

    • Preparing: Phase one is in progress.

    • Committing: Phase 1 is complete. The transaction is in the commit operation of Phase 2.

    • Rolling back: Phase 1 is complete. The transaction is in the rollback operation of Phase 2 because a business process failed.

  • Finished

    • Committed: The transaction is finished, and its data changes are committed.

    • Rolled back: The transaction is finished, and its data changes are rolled back.

  • Abnormal

    • Commit abnormal: Phase 1 is complete. An exception occurred during the commit operation in Phase 2.

    • Rollback abnormal: Phase 1 is complete. An exception occurred during the rollback operation in Phase 2.

    • Check-back abnormal: Phase 1 is complete. An exception occurred when checking back with the business API in Phase 2.