Database Reference
In-Depth Information
a distributed database environment, typically a transaction gets divided into sub-
transactions and executed at different sites. So each subtransaction must behave like
a complete transaction within a site. To preserve the atomicity of the entire trans-
action, either all subtransactions should commit or none at all. Whether any failure
occurs or not, the atomicity and durability properties must be ensured. These
are ensured by means of a proper commit protocol. The method for a centralized
environment must be enhanced. The two-phase commit is commonly used as the
standard for the distributed environment.
As you know, in a centralized database system the log file contains all the details
that can be used to recover from failures. In a distributed database system, each site
maintains a separate log file. These log files contain details of the actions performed
as part of the commit protocol in addition to the operations of the transactions
as in a centralized system. Recovery from failures in a distributed environment
depends on such additional details.
We will briefly discuss the commit protocol and the recovery process. We will
provide a summarized discussion without getting into too much technical detail. The
site from which a transaction originates is known as the coordinator site for the
transaction, and all other sites where subtransactions of the original transaction
execute are called subordinate or participant sites.
Two-Phase Commit Protocol (2PC)
As the name implies, actions in this proto-
col take place in two phases: a voting phase and a decision or termination phase.
The underlying principle is that the coordinator decides to commit a transaction
only when all participants vote to commit.
Now let us walk through the execution of a transaction while adopting the
protocol.
Voting Phase
The user transaction completes processing and decides to com-
mit. Write
begin-commit
record in the log file. Send
prepare
message to each
participant.
Termination Phase
On receiving a
prepare
message, each participant is either
ready to commit or abort based on local conditions. Each participant either writes
a
ready-commit
record in the local log file and returns a
ready-commit
message to
the coordinator or writes an
abort
message in the local log file and returns an
abort
message to the coordinator.
Case 1.
Any participant returns an
abort
vote based on local processing.
Write
abort
record in the log file. Send
global-abort
message to each participant.
The participant writes an
abort
record in the local log file and sends an
acknowl-
edgement
to the coordinator. The coordinator, on receiving all
acknowledgement
messages, writes
end-transaction
record in its log file.
Case 2.
All participants return
ready-commit
votes.
Write
commit
record in the log file. Send
global-commit
message to each partic-
ipant. The participant writes a
commit
record in the local log file, commits the sub-
transaction, releases all locks, and sends an
acknowledgement
to the coordinator.
Search WWH ::
Custom Search