InterviewHubPRO
Section Overview
Q27

Question 27 of 50

Part 3: Distributed Transactions, Consensus & Reliability (26 - 36)

54%
System Design (50 Qs)•Part 3: Distributed Transactions, Consensus & Reliability (26 - 36)

Two-Phase Commit (2PC) vs Three-Phase Commit (3PC).

In Simple Words: Atomic transaction protocols that ensure all participating database nodes either commit or abort a distributed transaction together.

  • Two-Phase Commit (2PC):
    • Phase 1 (Prepare): Coordinator asks all participants: "Can you commit?" Participants lock resources and respond YES/NO.
    • Phase 2 (Commit): If all vote YES, Coordinator broadcasts COMMIT. If any vote NO, broadcasts ROLLBACK.
    • Weakness: Blocking protocol. If Coordinator crashes after Phase 1, participants remain locked indefinitely.
  • Three-Phase Commit (3PC):
    • Adds a non-blocking Pre-Commit phase and timeouts to avoid indefinite lock starvation. Rarely used in practice due to network partition vulnerabilities.