Expand description
Intent-lock hierarchy adapter — Resource naming + LockerGuard RAII.
Thin layer over crate::storage::transaction::lock::LockManager
that gives the runtime dispatch paths a typed API:
- Read dispatch:
(Global, IS) → (Collection, IS) - Write dispatch:
(Global, IX) → (Collection, IX) - DDL dispatch:
(Global, IX) → (Collection, X)
The adapter owns:
- A
Resourceenum that maps the two hierarchy levels to the byte-key formatLockManagerexpects (no string collisions, cheap encoding). - A
LockerGuardthat records each(resource, mode)pair in acquisition order and releases them on drop. Releases run in reverse order so the global lock is the last to go. - A tiny monotonic
TxnIdallocator keyed by the current connection id — enough for deadlock detection to distinguish concurrent acquirers.
The adapter does not implement ordered-acquire enforcement
via phantom types yet (TODO for P1.T4); callers currently discipline
themselves by always going Global → Collection.
Structs§
- Locker
Guard - RAII guard over a set of acquired locks. Drop releases every
acquired resource in reverse-acquire order, so the common
Global → Collectionpath releasesCollectionfirst thenGlobal.
Enums§
- Acquire
Error - Outcome of a
try_acquire—Granted/Upgradedfall through to the guard, the rest bubble up as an error the caller can log or retry. - Resource
- Hierarchical resources the runtime locks on. The byte-key encoding
prefixes each level with a discriminator so
Collection("global")can never collide with the true global-scopeResource::Global.