---
title: "Short note: Three-phase commit"
subject: "Distributed System"
chapter: 8
key: "semester_7/distributed_system:three-phase-commit-note"
source: https://www.bctengineer.com/q/semester_7/distributed_system/three-phase-commit-note
site: BCT Engineering
---

# Short note: Three-phase commit

Distributed System · Chapter 8: Transaction and Concurrency Control

- Asked in: 2076 Chaitra, 3 marks
- Video: [🐣💔 23. Three Phase Commit Protocol🐣💔](https://www.youtube.com/watch?v=o0OAcd5B23c) — Rupali ma'am's class
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/distributed_system/three-phase-commit-note
- Whole chapter: https://www.bctengineer.com/md/semester_7/distributed_system/chapter-8

## Question

Write a short note on three phase commit.

## Short answer

Three-phase commit (3PC) extends 2PC with a pre-commit phase to prevent blocking on coordinator failure. Phases: canCommit (vote), preCommit (all know Yes votes), doCommit. If coordinator crashes, participants can elect a new coordinator; if any is in preCommit state, they commit, else abort. It avoids blocking but adds one message round.

## Answer

The **three-phase commit protocol (3PC)** is an extension of 2PC that avoids blocking when the coordinator crashes, by adding a **pre-commit** state between the vote and the commit. Its states satisfy two conditions: there is no state from which a process can move directly to both COMMIT and ABORT, and there is no state in which a process cannot yet make a final decision but can move directly to COMMIT.

**Phases**
1. **canCommit**: the coordinator sends *Prepare/canCommit?*; participants reply Yes or No. If any No, or a timeout, the coordinator sends abort.
2. **preCommit**: if all say Yes, the coordinator sends *Pre-commit*; participants acknowledge. Now everyone knows that all have voted Yes.
3. **doCommit**: after all acknowledgements, the coordinator sends *Commit*; participants commit and reply.

```text
Coordinator states:
 INIT --canCommit?--> WAIT --all Yes--> PRECOMMIT --acks--> COMMIT
                        |any No/timeout
                        v
                      ABORT

Participant states:
 INIT --Yes--> READY --preCommit--> PRECOMMIT --commit--> COMMIT
   |No          |abort/timeout
   v            v
 ABORT        ABORT
```

**Recovery rule**: if the coordinator fails, the participants elect a new one. If any participant is in PRECOMMIT, all can commit; if none is, all can abort. Timeouts drive transitions so the system never blocks indefinitely.

**Compared with 2PC**: 3PC is non-blocking under crash failures (not for network partitions), but needs one more round of messages, so it costs more and is less used in practice.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What problem does 3PC solve compared with 2PC?
   A. Blocking when the coordinator crashes
   B. Network partitions
   C. Message cost
   D. Lost updates
   Answer: A. The extra pre-commit state lets participants decide among themselves after a coordinator crash. (Key point: Purpose of 3PC)

2. What is the order of the 3PC phases?
   A. preCommit, canCommit, doCommit
   B. canCommit, doCommit, preCommit
   C. canCommit, preCommit, doCommit
   D. doCommit, canCommit, preCommit
   Answer: C. Vote, then pre-commit with acknowledgements, then final commit. (Key point: Three phases)

3. After a coordinator failure and election of a new one, when can all participants commit?
   A. If any participant is in PRECOMMIT
   B. If all participants are in INIT
   C. If none is in PRECOMMIT
   D. Only when the old coordinator recovers
   Answer: A. A participant in PRECOMMIT shows everyone voted Yes, so commit is safe; if none is, abort is safe. (Key point: Recovery rule)

## Related in Distributed System

- [Cascading aborts; three-phase commit](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Acascading-aborts-3pc) — Distributed System, chapter 8
- [Short note: Two-phase commit](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Atwo-phase-commit-note) — Distributed System, chapter 8, asked 2×
- [Distributed deadlock; two-phase commit](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adistributed-deadlock-2pc) — Distributed System, chapter 8

## Related in other subjects

- [Three phase system and transition zone](https://www.bctengineer.com/question.md?key=semester_5%2Fconcrete_technology_and_masonry_structure%3Athree-phase-transition-zone) — Concrete Technology and Masonry Structure, chapter 2, asked 8×
- [Output equation of three phase induction motor](https://www.bctengineer.com/question.md?key=semester_5%2Felectric_machine_design%3Ainduction-motor-output-equation) — Electric Machine Design, chapter 4, asked 6×
- [Three phase system and structure of hcp](https://www.bctengineer.com/question.md?key=semester_5%2Fconcrete_technology_and_masonry_structure%3Athree-phase-hcp-structure) — Concrete Technology and Masonry Structure, chapter 2, asked 6×
- [Three-phase single-way thyristor rectifier: average and RMS](https://www.bctengineer.com/question.md?key=semester_7%2Fpower_electronics%3A3ph-single-way-thyristor-avg-rms) — Power Electronics, chapter 3, asked 5×
