Two phase commit protocol The two phase commit protocol provides an automatic recovery mechanism in case a system or media failure occurs during execution of the transaction. The two phase commit protocol ensures that all participants perform the same action (either to commit or to roll back a transaction). The two phase commit strategy is designed to ensure that either all the databases are updated or none of them, so that the databases remain synchronized. In two phase commit protocol there is one node which is act as a coordinator and all other participating node are known as cohorts or participant. Coordinator – the component that coordinates with all the participants. Cohorts (Participants) – each individual node except coordinator are participant. As the name suggests, the two phase commit protocol involves two phases. The first phase is Commit Request phase OR phase 1 The second phase is Commit phase OR phase 2 Commit Request Phase (Obtaining Decision) To commit the transaction, the coordinator sends a request asking for “ready for commit” to each cohort. The coordinator waits until it has received a reply from all cohorts to “vote” on the request. Each participant votes by sending a message back to the coordinator as follows: It votes YES if it is prepared to commit It may vote NO for any reason if it cannot prepare the transaction due to a local failure. It may delay in voting because cohort was busy with other work. Commit Phase (Performing Decision) If the coordinator receives YES response from all cohorts, it decides to commit. The transaction is now officially committed. Otherwise, it either receives a NO response or gives up waiting for some cohort, so it decides to abort. The coordinator sends its decision to all participants (i.e. COMMIT or ABORT). Participants acknowledge receipt of commit or about by replying DONE.