Product Environment 9-47
Two-Phase Commit and Logical Log Records
The coordinator’s commit work record (COMMIT record) contains all infor-
mationneeded to initiate the two-phase commit protocol and it serves as the
starting point for automatic recovery in the event of a failure on the coordi-
nator’s host machine. Because this record is critical to recovery, it is not
allowed to remain in the logical log buffer. The coordinator must immedi-
ately flush theCOMMIT logical log record.
The participants inFigure 9-10 must immediately flush both the PREPARE
and the COMMIT logical log records. Flushing thePREPARE record ensures
that,if the participant’s host machine fails, fast recovery is able to determine
that this participant is part of a global transaction. As part of recovery, the
participant might query the coordinator to learn the final disposition of this
transaction.
Flushing the participant’sCOMMIT record ensures that, if the participant’s
host machine fails, the participant has a record of what action it took
regarding the transaction. To understand why this is crucial, consider the
situation in which a participant crashes after thePREPARE record is written
but before theCOMMIT record flushes. After fast recovery, the PREPARE
recordis restored but the COMMIT record is lost (since it was in the logical log
bufferat the time of the failure). The existence of the PREPARE record would
initiatea query to the coordinator about the transaction. However, the coordi-
nator would know nothing of the transaction since it ended the transaction
afterit received the participant’s acknowledgment that the commit occurred.
Inthis situation, the participant would interpret the lack of information as a
final direction to roll back the transaction. The two-phase commit protocol
requiresthe participant COMMIT record to be flushed immediately to prevent
this kind of misunderstanding.