Database Latches and Transaction Locks
Separate short protection of an in-memory structure from the longer logical protection an isolation protocol can require.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
A latch protects the representation during an operation
A page latch can prevent another thread from changing slot metadata while a reader copies it. Its scope is normally a short internal critical section. Releasing it means the structure is again safe to manipulate under that latch discipline. It says nothing by itself about whether the caller’s transaction may keep reading a consistent value in later operations.
A transaction lock protects logical access
A lock on a row or range can coordinate conflicting transactions for a longer interval. A range lock may protect absence or eligibility for a predicate beyond any one currently stored row. Latch ordering and lock acquisition have different cost and deadlock considerations. Mutex invariants explain the short critical-section reasoning. Two-phase locking explains an isolation rule based on the order of logical acquisition and release.[1][2]