- 2076 Chaitra · 4+4 marks
Approaches to avoid distributed deadlock
Short answer
Deadlock can be avoided by acquiring all locks at start, enforcing a global resource ordering to prevent cyclic waits, using lock timeouts, or applying timestamp-based schemes: wait-die aborts younger requesters, wound-wait preempts younger holders, so waits only flow from younger to older, preventing cycles. Optimistic or timestamp ordering concurrency control also avoids locks entirely.
What are the alternative approaches to avoid possibility of deadlock in distributed system? Explain.
A deadlock happens when transactions wait for each other's locks in a cycle. It can be prevented by breaking one of its necessary conditions (mutual exclusion, hold and wait, no pre-emption, circular wait). The alternative approaches are:
- Lock all objects at the start (no hold and wait): a transaction acquires all its locks at the start in one atomic step. It is simple but wastes concurrency, and the required objects are often not known in advance.
- Ordering of resources (no circular wait): lock objects in a fixed global order. A transaction cannot request an earlier object while holding a later one. This is hard to apply across many servers.
- Timeouts: a lock is valid for a limited time. After the time limit, the lock is vulnerable; if another transaction wants it, the holder is aborted. Easy, but it aborts transactions that were only slow, and the timeout value is hard to choose.
- Timestamp-based prevention (each transaction has a unique timestamp, older = smaller):
- Wait-die (non-pre-emptive): if the requester is older than the holder, it waits; if younger, it dies (aborts and restarts with the same timestamp).
- Wound-wait (pre-emptive): if the requester is older, it wounds (aborts) the holder; if younger, it waits. In both, waiting goes in only one direction (by age), so no cycle can form, and there is no starvation because a restarted transaction keeps its original timestamp.
- Optimistic or timestamp ordering concurrency control: no locks, so no deadlock.
If avoidance is too restrictive, detection and recovery (wait-for graph, edge chasing, abort a victim) are used instead.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Distributed deadlock and recovery · Distributed System, chapter 8 · asked 3×
- Distributed deadlock; two-phase commit · Distributed System, chapter 8
- Lock; distributed CC; deadlock situation · Distributed System, chapter 8
- Autonomous vs distributed system · Distributed System, chapter 1
- Models of distributed system · Distributed System, chapter 1
- True distributed system; middleware organisation · Distributed System, chapter 3
- Distributed system in big data example · Big Data Technologies, chapter 1
- Short note: Distributed system implementation · Object Oriented Analysis and Design, chapter 4
- Distributed system and Hadoop · Information System, chapter 8
- Race condition; critical section approaches · Operating System, chapter 3