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:
-
Lock Database in IS mode
-
Lock Area A1 in IS mode
-
Lock File Fa in IS mode
-
Lock Record ra2 in S mode