Skip to main content
InterviewHubPRO
Section Overview
Q29

Question 29 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

58%
SQL & Relational Databases (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

What is Two-Phase Commit (2PC) in Distributed Databases?

senior LevelSystem DesignDatabases & SQL

In Simple Words: Guarantees atomic transactions across multiple distributed database nodes:

  1. Prepare Phase: Coordinator asks all participant nodes if they can commit. Each node acquires locks, writes to WAL, and responds VOTE_COMMIT or VOTE_ABORT.
  2. Commit Phase: If all vote commit, coordinator sends GLOBAL_COMMIT. If any node votes abort, coordinator sends GLOBAL_ABORT.
  • Drawback: Blocking protocol; if coordinator crashes mid-commit, participants remain locked in doubt.