seniorSQL

What is two-phase commit (2PC)?

Updated May 17, 2026

Short answer

2PC is a distributed protocol that ensures all nodes commit or rollback together.

Deep explanation

Two-phase commit has a coordinator and participants. Phase 1 (prepare): all participants agree they can commit. Phase 2 (commit/abort): coordinator instructs commit if all agree, otherwise abort. It ensures atomicity but can block if coordinator fails.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More SQL interview questions

View all →