Understand Distributed transaction & Two-Phase Commit
A Distributed transaction includes one or more statements that, individually or as a group, update data on two or more distinct nodes of a distributed database.
A distributed transaction is considered committed after all non-commit-point sites are prepared, and the transaction has been actually committed at the commit point site.
Distributed Transaction terms:
The database defines a session tree of all nodes participating in the distributed transaction.
Client which refer information from another database node.
Database Server which host a database from which a client request data.
A node that refer to another node for data to complete its transaction.
Node from which transaction is originating.
System always choose one node to be commit point site.
Two-Phase Commit Mechanism
In Distributed Environment alerting data involves the multiple databases. In this committing or rolling is managed as a complete process means the entire transaction commits or the entire transaction rolls back. For maintain the integrity of data in a distributed transaction using the two-phase commit mechanism.
It includes phases:
Prepare Phase: global coordinator ask all Participating nodes other than commit site to promise for commit or rollback the transaction. if any node is cannot prepare then completed transaction is rollback.
Commit Phase: All nodes informed the coordinator at commit site that they are prepared and having all the needed resources for commit the transactions then coordinator ask commit site to commit. After commit all participating ask for commit the transaction.
Forget Phase: After got conformation from all nodes by the coordinator that they all are committed then commit site forget the transaction.
For more info: Understand In Doubt Transaction