Younger transactions requesting locks held by older ones are aborted ("die") to break potential deadlocks.
Wound-Wait Scheme:
Older transactions "wound" (preempt) younger transactions holding locks, forcing the latter to abort.
Younger transactions wait if the lock holder is older.
Effect: Avoids cycles by prioritizing older transactions to prevent indefinite waits.
3. Conservative Two-Phase Locking (Preclaiming)
Mechanism: A transaction declares all required locks upfront and acquires them atomically before execution begins.
Effect: Eliminates the "hold-and-wait" condition (one of the four deadlock conditions) by ensuring no partial lock acquisition.
Drawback: Reduces concurrency since locks are held longer.
4. Resource Hierarchy
Mechanism: Define a strict hierarchy for resources (e.g., databases > tables > pages > tuples). Locks must be acquired starting from higher levels in the hierarchy.
Effect: Prevents circular waits by restricting lock acquisition order.
5. Avoiding Hold-and-Wait
Mechanism: Ensure transactions request all locks they need before starting execution (similar to preclaiming).
Effect: Eliminates the possibility of a transaction holding some locks while waiting for others.
Key Notes:
Deadlock Avoidance vs. Detection: Avoidance focuses on preventing deadlocks proactively, while detection identifies and resolves existing deadlocks (e.g., via timeouts or wait-for graphs).
Trade-offs: Avoidance methods like lock ordering and preclaiming can limit concurrency or require upfront knowledge of resource needs.
Practical Use: In real-world databases, deadlock detection with timeouts or aborts is often preferred over strict avoidance due to complexity and performance considerations.
These methods ensure transactions proceed without entering deadlock states, maintaining system reliability and performance.