- 2071 Chaitra · 3 marks
Short note: Flat versus nested locks
Short answer
Flat locks are held by a single transaction and released at commit/abort, conflicting with any other transaction. Nested locks allow sub-transactions to acquire locks; a child can lock if conflicting holders are ancestors, and upon commit locks are inherited by the parent, increasing intra-transaction concurrency while maintaining serial equivalence.
Write a short note on flat versus nested locks.
In a flat transaction locks are held by one transaction, and the usual rules apply: locks are acquired as objects are accessed (growing phase), and under strict 2PL all are released together at commit or abort. Two locks conflict if they are from different transactions and at least one is a write.
In nested transactions, locks belong to sub-transactions, and the following rules are used (Moss):
- A sub-transaction can acquire a read lock if every other holder of a write lock on the object is an ancestor.
- It can acquire a write lock if every other holder of a read or write lock is an ancestor.
- When a sub-transaction commits, its locks are inherited by its parent (the parent now holds them).
- When a sub-transaction aborts, its locks are discarded; if the parent held the lock earlier, it still holds it.
| Point | Flat locks | Nested locks |
|---|---|---|
| Holder | One transaction | Sub-transaction (and parent by inheritance) |
| Release | At commit/abort | Passed to parent at child commit; final release at top level |
| Concurrency | Between top-level transactions | Also between siblings, within a transaction |
| Conflict rule | Any other transaction | Non-ancestors only |
Nested locking increases concurrency inside a transaction while keeping serial equivalence among siblings.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Flat/nested transactions; concurrency control · Distributed System, chapter 8
- Flat/nested transactions; optimistic CC · Distributed System, chapter 8
- Flat roof versus pitched roof · Building Technology, chapter 4 · asked 2×