Concurrency Control
It is the function of the transaction manager of a distributed database system to manage the execution of those transactions (or subtransactions) that access data store in a local site. Note that each such transaction may be either a local transaction (that is, transaction that only executes at that site) or part of a global transaction (that is, a trasaction that executes at several sites). Each transaction manager is responsible for maintaining a log for recovery purpose, and for participating in an appopriate concurrency-control scheme to coordinate the concurrent execution of the transactions executing at that site.
Locking Protocols
The only change that needs to be incorporated is in the way the lock manager is implemented. We present several possible schemes, the first of which deals with the case where no data replication is allowed. The other scheme are applicable to themore general case where data can be replicated in several sites.
Nonreplicated Scheme
If no data are replicated in the system. Each site maintains a local lock manager whose function is to administer the lock and unclock requests for those data items that are stored in that site. When a transaction wishes to lock data item Q at site Si, it simply sends a message to the lock manager at site Si requesting a lock (in a particular lock mode). If data item Q is locked in an incompatible mode, then the request is delayed until that request can be granted. Once it has been determined that the lock request can be granted, the lock manager sends a message back to their initiator indicating that the lock request has been granted.
The scheme has the advantage of simple implementation. It request two message transfers for handling lock request, and one message transfer for handling unlock request. However, deadlock handling is more complex. Since the lock and unlock request are no longer made at a single site, the various deadlock-handling algorithms.
Single-Coordinator Approach
Under the single-coordinator approach, the system maintains a single lock manager that resides in a single chosen site, say Si. All lock and unlock requests are made at site Si. When a transaction needs to lock a data item, it sends a lock request to Si. The lock manager determines whether the lock can be granted immediately. If so, it sends a message to that effect to the site at which the lock request was initiated. Otherwise, the request is delayed until it can be granted, at which time a message is send to the site at which the lock request was initiated. The transaction can read the data item from any one of the sites at which a replica of the data item resides. In the case of a write, all the sites where a replica of the data item resides must be involved in the writing.
The scheme has the following advantages:
Simple implementation: This scheme requires two message for handling lock requests, and one message for handling unlock requests.
Simple deadlock handling: Since all lock and unlock requests are made at one site, the deadlock-handling algorithms can be applied directly to this environment.
The disadvantages of the scheme include the following;
Bottleneck: The site Si becomes abottleneck, since all requests must be procecced there.
Vulnerability: If the site Si fails, the concurrency controller is lost. Either processing must stop or a recovery scheme must be used.
A compromise between these advantage and disadvantages can be achieved through a multiple-coordinator, in which the lock-manager function is distributed over several sites.
Each lock manageer administers the lock and unlock requests for a subset of the data item. Each lock manager resides in a different site. This distribution reduces the degree to which the coordinator is a bottleneck, but it complicates deadlock handling, since the lock and unlock requests are not made at one single site.
Majority Protocol
The majority protocol is a modification of the nonreplicated data sheme that we presented earlier. The system maintains a lock manager at each site. Each manager manages the locks for all the data or replicas of data stored at that site. When a transaction wishes to lock a data item Q, which is replicated in n different sites, it must sent a lock request to more than one-half of the n sites in which Q is stored. Each lock manager determines whether the lock can be granted immediately (as for as it is concerned). As before, the response is delayed until the request can be granted. The transaction does not operate on Q until it has successfully obtained a lock on a majority of the replicas of Q.