Database Reference
In-Depth Information
BEGIN
BEGIN
Send
prepare
message
Receive
prepare
message
Receive
participant votes
Send
ready-
commit
message
Ready to
commit?
Send
abort
message
Send
global-
abort
message
Send
global-
commit
message
Commit
vote?
Receive
global
message
Global
commit?
Receive
participant
ack
Perform local
abort
Perform local
commit
Commit
ack?
Perform
global commit
Perform
global abort
Send
ack
message
END
END
Coordinator
Participant
Figure 18-24
Two-phase commit: action states.
The coordinator, on receiving all
acknowledgement
messages, writes
end-transaction
record in its log file.
While these actions take place, the coordinator and the participants go through
four states as illustrated in Figure 18-24.
Recovery
Consider a site coming back up after a crash. The recovery process
of the DDBMS gets initiated, and it reads the local log file. It takes suitable recov-
ery actions by processing all the log records for the transactions that were execut-
ing the two-phase commit protocol at the time of the crash. Note that this site could
have been the coordinator for some of these transactions and a participant for
others.
The following indicates the recovery process in a general manner. This is not
a detailed discussion. Assume that transaction T is one of those for which the
recovery process applies.
Case 1.
Commit
or
abort
record exists in the log file.
If
commit
record exists, redo T; if
abort
record exists, undo T. If this site happens
to be the coordinator for T, resend
commit
or
abort
message to all participants
because there may be other site or link failures. When
acknowledgements
are
received back from all participants, write
end-transaction
record in the log file.
Case 2.
Prepare
record exists, but no
commit
or
abort
record in the log file.
This site is a participant. Find coordinator site from
prepare
record and contact
coordinator for status of T. If coordinator responds with a
commit
message, write
Search WWH ::
Custom Search