Ensuring Atomicity in Distributed Systems
The Two-Phase Commit (2PC) Protocol is a distributed algorithm used to ensure that a transaction involving multiple, independent systems (or nodes) is executed atomically. That means either all nodes commit the transaction, or none of them do—keeping the system in a consistent state.
Think of 2PC as a coordinated "yes or no" voting process among all the participants in a transaction. If everyone agrees (votes "yes"), the transaction is committed. If even one participant votes "no," the entire transaction is rolled back.