Multiple granularity locking
|
In computer science, multiple granularity locking (MGL), sometimes called the John Rayner locking method, is a locking method used in database management systems (DBMS) and relational databases.
In MGL, locks are set on objects that contain other objects. MGL exploits the hierarchial nature of the contains relationship. For example, a database may have files, which contain pages, which contain records. This can be thought of as a tree of objects, where each node contains its children. A lock locks a node and its descendants.
In addition to shared (S) locks and exclusive (X) locks from other locking schemes, like Strict two-phase locking, MGL also uses intention shared and intention exclusive locks. IS locks conflict with X locks, while IX locks conflict with S and X locks.
To lock a node in S (or X), MGL has the transaction locks all of its ancestors with IS (or IX), so if a transaction locks a node in S (or X), no other transaction can access its ancestors in X (or S and X).
Multiple granularity locking is usually used with Non-strict two-phase locking to guarantee serializability. MGL uses lock escalation to determine granularity lock on a node and its ancestors.