Databases Reference
In-Depth Information
transactions that had not committed at the time of the failure, thus ensuring
the atomicity property.
9.5.1
Distributed Concurrency Control
The most common approach to concurrency control in centralized DB
systems is to use two-phase locking (2PL), in which transactions must first
obtain the locks they require in a growing phase before releasing the locks
in a shrinking phase. Often the shrinking phase is conducted only when
the transaction commits, resulting in what is termed strict 2PL. However,
this method presents the problem that two or more transactions may enter a
deadlock state, in which each transaction holds locks required by the others
and all the transactions are unable to proceed.
In a DDB, the locks obtained by 2PL must be distributed to the vari-
ous sites that form the DDB, and some action must to taken to ensure that
2PL is obeyed globally over the DDB. There must also be some distributed
deadlock-detection mechanism. To illustrate this discussion, we give several
examples based on the two transactions shown in Figure 9.6, representing
a fragment of a simple banking application operating on the relations in
Figure 9.3(b). The transactions have been written so that it is clear which
parts of each transaction need to operate on a particular fragment of the data.
The read and write operations performed by the transactions are shown to
the right of the SQL statement that performs the operations.
9.5.1.1 Distributed Two-Phase Locking
It might at first appear that it would be sufficient to run 2PL on each LTM
involved in the distributed transaction. Indeed, that will ensure that the
transactions executed at each server are locally serializable. However, the seri-
alization order chosen may vary between LTMs, and thus the transaction
may not be globally serializable. That is because one server may start its
shrinking phase before the other starts its growing phase. To prevent that
from occurring, 2PL must be applied to the global transaction sequence. In
principle, that might be achieved by a protocol to ensure that GTM controls
when the shrinking phase may begin on each LTM. In practice, the usual
solution is to use strict 2PL and the atomic commitment protocols discussed
in Section 9.5.2 to ensure that all locks are released at the same time.
9.5.1.2 Distributed Locks
One crude implementation of distributed locking would be to insist that
each read and write lock must fully replicated, matching the replication of
Search WWH ::




Custom Search