
- Concurrency Control In Distributed Databases
- Nature of the Database 1. Partitioned 2. Partially replicated 3. Fully replicated
- Concurrency Control Strategies 1. Write Locks All (Read Locks one) Protocol . to read, lock one copy of the item . to write, all copies of the item must be locked Analysis . Assume n nodes have a copy of the item Write Locks n requests n ACKs n writes --------------------------------------------------------- Total = 3 n (2n short, n long) --------------------------------------------------------- Read Locks 1 request 1 ACK and read value --------------------------------------------------------- Total = 2 (1 short, 1 long) --------------------------------------------------------- 2. Majority Locking Strategy Protocol . to obtain a read lock or a write lock a majority of the copies must be locked Analysis Write Locks (n+1)/2 requests (n+1)/2 ACKs n write --------------------------------------------------------- Total = 2n + 1 (n+1 short, n long) Read Locks (n+1)/2 requests (n+1)/2 Acks, and a read value --------------------------------------------------------- Total = n+1 (n short, 1 long) 3. Primary Copy Method Protocol . a primary site is identified for each item (this site is responsible for the management of all copies of that item) Analysis Write Locks 1 request to primary site 1 ACK n writes -------------------------------------------------------- Total = n + 2 (2 short, n long) -------------------------------------------------------- Read Locks 1 request to primary site 1 ACK & read value -------------------------------------------------------- Total = 2 (1 short, 1 long) **1**: Central site for each item **2**: Centralized approach **3**: Failure & Bottleneck 4. Central Node Method Protocol . A single node is responsible for all locks on all items . Write lock: send request to central site; send response to requester; issue writes .Read lock: send request to central site; if lock granted, forward request to a node with the data; data is transmitted Analysis Write locks: 1 request to central site 1 ACK n writes -------------------------------------------------------- Total = n + 2 ( 2 short, n long) -------------------------------------------------------- Read Locks 1 request to central site 1 forwarding to data node 1 data message -------------------------------------------------------- Total = 3 (2 short, 1 long) Note: Central site may be bottleneck or point of vulnerability 5. Baton Passing Protocol . Locking information is replicated at all nodes . only one node can modify the locking information at any time with updating control by a floating baton . the node with the baton can modify the locking information . changes to the locking information are packaged in an update message that is circulated . the baton is passed to next node after all changes have been made Analysis Write Locks 0 request local node n writes ---------------------------------------------------------- Total = n (n long) ---------------------------------------------------------- Read Locks 0 request local node 1 request data 1 data transfer ---------------------------------------------------------- Total = 2 ( 1 long, 1 short) ---------------------------------------------------------- Note: Total number of messages have been reduced but response time is increased because transactions are batched at each node until the baton arrives.
- Distributed Timestamps Timestamps Representation Local clock value| node identification Clock Realignment . Each message must bear a timestamp . If a node receives a message with a timestamp indicating a future time, the local clock is readjusted to the local clock value of the timestamp
- Rosenkrantz, Lewis, and Stearns Models Transaction is composed of sequential steps that may need to access and update data objects at different sites Two protocols . WAIT-DIE If requester is older then Requester waits Else Requester dies . WOUND-WAIT If requester is older then Requester wounds Else Requester waits WAIT: Transaction waits until the conflicting transaction terminates or aborts DIE: Transaction making request restarts RESTART: . Transaction first aborts (returns all modified data to the original values) . Process then begins again at the original site retaining the original timestamp WOUND: . a message is sent to all sites a wounded process has visited to say that it is wounded . If the wound message is received before the transaction has begun termination (i.e.,Committing changes), the concurrency control at that site initiates a restart of the wounded transaction . If wound message is received after termination begun, the message is ignored and the transaction allowed to complete.
Last update March 2, 1998.