Two-phase commit for federated transactions

A federated system can use two-phase commit for transactions that access one or more data sources. Two-phase commit uses the industry standard X/Open XA protocol to coordinate the processing of distributed unit of work transactions.

In a two-phase commit operation, commit processing occurs in two phases: the prepare phase and the commit phase. During the prepare phase in a federated system, a federated server polls all of the federated two-phase commit data sources that are involved in a transaction. This polling activity verifies whether each data source is ready to commit or roll back the data. During the commit phase, the federated server instructs each two-phase commit data source to either commit the data or to roll back the transaction.

In a one-phase commit environment, multiple data sources are updated one data source at a time using separate commit operations. This can cause data synchronization problems if some data sources are successfully updated and others are not.

For example, if a transaction withdraws funds from one account and deposits them in another account 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 withdraw operation cannot because it has already been successfully committed. The result is that the funds are virtually "lost".

In a two-phase commit environment, the withdraw 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.