Download presentation
Presentation is loading. Please wait.
1
18.5 An Architecture for Locking Scheduler
By Siddiq Ahmed Syed Roll No:7
2
Principles of simple scheduler architecture:
Transactions cannot request for lock ,it is the scheduler that take cares of it. Scheduler inserts the lock and release the lock when it is notified by the transaction manager
3
18.5.1 A Scheduler That Inserts Lock Actions
It is a two part scheduler Maintains a lock table and it is one of the component of the DBMS Scheduler take cares of the actions which are requested by the transactions Part I handles all the requests generated by the transactions and inserts lock actions in front of all database access operations The data base access actions are transmitted to Part II From transactions READ(A);WRITE(B); COMMIT(T);.. Scheduler I LOCK TABLE LOCK(A);READ(B);.. Scheduler II READ(A);WRITE(B); Fig: Scheduler
4
Cont.. Part II is responsible for performing the database access actions passed by part I. If its an access request , Part II determines whether the issuing transaction (T) is already delayed. If transaction (T) is delayed, the action itself delayed and added to a lit of actions that must be performed for transaction (T).
5
Cont.. If transaction (T) is not delayed, then
(a) If the action is a database access, it is transmitted to the database and executed. (b) If a lock action is received by Part II, it examines the lock table to see if the lock can be granted. i. If so, the lock table is modified to include the lock just granted. ii. If not, an entry must be made in the lock table to indicate that the lock has been requested.
6
Cont.. When a transaction (T) commits or aborts, Part I is notified by the transaction manager, and releases all locks held by (T). If any transactions are waiting for any of these locks, Part I notifies Part II. When Part II is notified that a lock on some database element X is available, it determines the next transaction or transactions that can now be given a lock on X
7
The Lock Table The lock table is a relation that associates database elements with locking information about that element The table can be implemented with hash table ,hash key would be the address of the database elements. Db element A Lock information for A
8
The entry shown for a typical database element A is a tuple with the following components
The group mode contains information of the most precise conditions that a transaction requesting a new lock on A faces. The waiting bit tells that there is at least one transaction waiting for a lock on A List contains the information of the transactions that either holds or wait for lock on A.List may include i. the name if transaction holding or waiting for a lock. ii. the mode of this lock iii. Whether the transaction is holding or waiting for the lock
9
Handling Lock Request If transaction T request a lock on A and there is no entry for A in lock table then the request is granted and an entry is created in the lock table If there is already lock table entry for A then it is used to guide the decision about the lock request No other locks are granted if there is an update lock on an element. So the request by T is denied and an entry will be placed on the list saying T request a lock. If group mode had been shared then another shared or update lock would be granted Whether or not the lock is granted ,the entry in the lock table tells the scheduler what it needs to do
10
Handling Unlocks If transaction T unlocks A then the T’s entry on the list for A is deleted. If the lock held by T is not the same as the group mode then there is no reason to change the group mode. If T’s lock in the group mode then examine the entire list to find the new group mode.
11
Cont.. If waiting is yes then we need to give one or more locks from the list of request locks. This can be done in one of these following ways First-come-first Served: Longest waiting is granted the lock request no starvation Priority of shared locks: Grant all the shared lock waiting along with one update lock if there are any waiting Grant exclusive lock if no other are waiting May lead to starvation Priority to upgrading: Grant that transaction first which is requesting for lock upgrade or else follow one of the above strategies
12
Reference: Database Systems: The Complete Book (2nd Edition) by Hector Garcia-Molina (Author), Jeffrey D. Ullman (Author), Jennifer Widom (Author)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.