Course contentsShow
← System Design
Lesson 572 of 1,91916. Distributed TransactionsFree lesson

Participant State Transitions

The states participants move through: ready, prepared, committed, or aborted.

Participant State Transitions

What you'll learn: How participants in a two-phase commit protocol move through different states as the transaction progresses.

The State Journey

In two-phase commit (2PC), each participant database doesn't just flip from "uncommitted" to "committed" instantly. Instead, it moves through a carefully choreographed sequence of states that mirror the protocol's phases:

  1. Ready (initial state) — The participant is idle, ready to receive a prepare request
  2. Prepared — After Phase 1, the participant has voted "yes" and locked resources, but hasn't committed yet
  3. Committed — After Phase 2, the participant has permanently applied the transaction
  4. Aborted — The transaction was rolled back (could happen from any state)

Why These States Matter

Think of it like a wedding ceremony. Guests are initially ready to attend. When they arrive and sit down, they're prepared (committed to staying). After the ceremony completes, they're committed (witnessed the marriage). If the wedding is canceled at any point, everyone moves to aborted and goes home.

The prepared state is crucial — it's where the participant has promised to commit, locked all necessary resources, and written its intention to durable storage. It cannot back out now without coordinator instruction. This state represents the "point of no return" for individual participants.

From ready, a participant can jump directly to aborted if it votes "no" during prepare. From prepared, it must wait for the coordinator's decision. Only the coordinator determines whether participants move from prepared to committed or aborted.

Key Takeaway: Participants transition through ready → prepared → committed states during successful 2PC, with the prepared state representing a critical commitment point where participants have promised to complete the transaction but haven't yet done so.