In a successful database update in a Two-phase commit session, there are several critical events that take place in the following order:
- The application reads or updates (or both) the participant databases.
- After all database accesses in the logical unit of work have completed successfully, the application directs the coordinator to commit the updates.
- The coordinator sends a prepare to commit request to all participants.
- If the participant can commit the work, it externalizes its journal entries, retains any write locks obtained in the logical unit of work, and responds affirmatively to the coordinator‘s prepare to commit request.
- The coordinator collects all the responses to the prepare to commit request and, if all are affirmative, enters the commit phase and sends commit requests to all participants.
- The participants irrevocably commit the updates and release the write locks.
- The participants respond to the coordinator’s commit request with a confirmation that the commit has been successfully completed.
- The application receives control at the statement following its commit request from step 2, above.