Two-Phase Commit

Atomic commit protocol for distributed transactions

Phase 1: PreparePhase 2: Commit
CoordinatoridleP1idlewill YESP2idlewill YESP3idlewill YESP4idlewill YES

Click participants to toggle their vote (before starting)

Current States

Coordinatoridle
P1idle
P2idle
P3idle
P4idle

Activity

Start transaction to see activity

How 2PC Works:

  • Phase 1 (Prepare): Coordinator asks all participants to prepare
  • Vote Yes: Participant can commit, locks resources
  • Vote No: Participant cannot commit, transaction aborts
  • Phase 2: Coordinator sends COMMIT (all yes) or ABORT (any no)