A federated system can use two-phase commit for transactions that access one or more data sources. Two-phase commit can safeguard data integrity in a distributed environment.
Consider these differences between one-phase commit and two-phase commit:
For example, if a transaction withdraws funds from one account and deposits them in another account by using one-phase commit, the system might successfully commit the withdraw operation and unsuccessfully commit the deposit operation. The deposit operation can be rolled back, but the withdrawal operation cannot because it already successfully committed. The result is that the funds are virtually "lost."
In a two-phase commit environment, the withdrawal and deposit transactions are prepared together and either committed or rolled back together. The result is that the integrity of the fund amounts remains intact.