Two-phase commit

Two-phase commit enables you to update multiple, disparate databases within a single transaction, and commit or roll back changes as a single unit-of-work.

As a transaction manager, InfoSphere® Classic Federation Server for z/OS® prohibits updates to more than one database system in a single unit-of-work. There is no guarantee that changes to all databases will be committed or rolled back together. Without two-phase commit, a successful commit to one database followed by a failed commit (and thus a rollback) to another database would create a partial update, and therefore cause the databases to be out-of-sync.

In general, all database systems that support transactions act as a syncpoint manager for changes made to application data. As a syncpoint manager, these databases maintain a log of changes and can roll back one or more changes to data if the application requests a rollback. In two-phase commit processing, the role of syncpoint manager is moved to an external agent, and each database manager acts as a participant in the two-phase commit process. In two-phase commit processing, applications request commit or rollback processing from the external syncpoint manager instead of the database system itself.

To ensure database integrity, external syncpoint managers must keep a separate log of database activity so that database transactions can be committed or rolled back in the event of a system failure. Because failures can occur at any point during two-phase commit processing, the syncpoint manager must be able to restart at any future point-in-time and know exactly where the two-phase process ended at the time of the failure.

In some cases, the state of a transaction might be classified as in-doubt and require a manual decision to determine if the transaction should be committed or rolled back. This is particularly true if the failure occurred somewhere in the middle of phase one processing. In this case, the transaction is in a state where a commit might still be able to proceed, but the application has the option of rolling back.