Page 6: Multiple Granularity Locking

Different Lock Sizes for Different Needs

Like parking spaces - sometimes you need a single spot, sometimes the entire parking lot.

Locking a node implicitly locks all its descendants in the same mode.

Hierarchy Example:

Database
  ├── Area A1
  │   ├── File Fa
  │   │   ├── Record ra1
  │   │   └── Record ra2
  │   └── File Fb
  └── Area A2

Intention Locks

Before locking a node, place intention locks on all ancestors.

Lock Types:

  • IS (Intention Shared): Planning to read something below

  • IX (Intention Exclusive): Planning to write something below

  • SIX (Shared + Intention Exclusive): Reading this level, writing below

  • S (Shared): Reading this level

  • X (Exclusive): Writing this level

Compatibility Matrix:

     IS  IX   S  SIX  X
IS   ✓   ✓   ✓   ✓   ✗
IX   ✓   ✓   ✗   ✗   ✗
S    ✓   ✗   ✓   ✗   ✗
SIX  ✓   ✗   ✗   ✗   ✗
X    ✗   ✗   ✗   ✗   ✗

Example: To read record ra2:

  1. Lock Database in IS mode

  2. Lock Area A1 in IS mode

  3. Lock File Fa in IS mode

  4. Lock Record ra2 in S mode

Updated on