Multiple Granularity Locking Protocol
Consider the following tree structure.
Here, a database is divided into areas, and each area is divided into files, and each file is divided into records.
Each node in a tree can be locked separately.
We have two types of locks:
- Shared Lock
- Exclusive Lock
When the transaction locks a node, in either a shared/exclusive lock mode, the transaction implicitly locks all the descendants of that node in the same lock mode.
i.e., if the transaction Ti gets an explicit lock on file FILE-A of the above figure, in exclusive mode, then it has an implicit lock in exclusive mode on all the records belonging to that file. It need not lock the individual records of FILE-A explicitly.
If a node is locked in Intension mode, explicit locking is done at a lower level of the tree.
An intention lock is something when a lower granularity object needs a lock and then the lock manager places a lock on the higher granularity object.
That is, intention locks are put on all the ancestors of the node before the node is locked explicitly.