Definition
A distributed protocol that coordinates an atomic commit across multiple participants by splitting the decision into a prepare phase (collect votes to commit/abort) and a commit phase (instruct participants to finalize), aiming to ensure atomicity of a distributed transaction.
Principle
Principle
A coordinator asks participants to prepare and persist their readiness; if all vote to commit the coordinator instructs commit, otherwise it instructs abort. Durable logging and deterministic recovery at participants are required to preserve correctness across failures.
Demonstration
Demonstration
A transaction updates two database shards: the coordinator sends prepare to both; each shard writes a 'prepared' record and replies 'yes'; the coordinator then issues commit and both shards make changes durable and release locks, guaranteeing both shards commit or both abort.
Misapplication
Misapplication
Using 2PC without durable logs or without handling coordinator failure, expecting it to be non-blocking, or applying it under frequent partitions without availability measures—this can lead to indefinite blocking or lost progress.
Consequence
Consequence
Strong atomic commit semantics across participants (either all commit or all abort) at the cost of potential blocking and coordination overhead; it simplifies correctness reasoning but can reduce availability under failures.
Reversal
Reversal
Optimistic or eventual-commit approaches (e.g., eventual consistency or compensation) that favor availability and liveness over globally atomic commits and accept temporary inconsistency.
Boundary
Boundary
Ensures atomic decision when participants respond and durable state exists, but does not guarantee progress under coordinator failure (it can block) and does not by itself tolerate network partitions; enhancements (e.g., three-phase commit or consensus-based commits) are needed for non-blocking guarantees.
Semantic Tension
Semantic Tension
Atomic, blocking coordination (2PC) versus non-blocking, consensus-based commit protocols (or eventual consistency): trade-offs between strong consistency and availability/liveness in distributed systems.
Synthesis
Synthesis
A coordinator-driven two-step handshake—prepare then commit—that enforces atomicity of distributed transactions by requiring unanimous prepared votes and durable logging, trading potential blocking and availability impacts for correctness across participants.