Two-Phase Commit (2PC) is a distributed consensus protocol that ensures atomicity across multiple nodes by coordinating them to either collectively commit or abort a transaction. It operates through two distinct phases: a prepare phase, where a coordinator queries participants if they are ready to commit, and a commit phase, where the coordinator instructs all participants to finalize the transaction based on unanimous readiness. This guarantees that all nodes reach the same final state, preventing partial updates.
