DSW.

Advanced

Distributed Deadlock Detection

Article diagram
May 3, 2026·11 min read

Distributed deadlock detection requires reasoning about a globally partitioned wait-for graph under message delays, making probe-based algorithms like Chandy-Misra-Haas the most principled approach despite widespread preference for simpler timeout mechanisms in practice.

Deadlock is a fundamental problem in concurrent systems: a set of processes each holds resources while waiting to acquire resources held by others, forming a circular dependency that prevents any of them from making progress.
In a single-node system, deadlock detection is well understood.
You build a wait-for graph (WFG), look for cycles, and resolve them.
In a distributed system, the problem becomes substantially harder because the WFG is partitioned across multiple nodes, no single node has a complete view of the system state, and messages between nodes introduce delays that can lead to phantom deadlocks.

This article covers the core challenges, the major algorithmic approaches, and the practical tradeoffs in distributed deadlock detection.

The Problem

diagram-1
The Problem

A distributed system consists of multiple sites (nodes), each managing local resources and processes.
A process at site A may request a resource held by a process at site B.
The global wait-for graph is the union of all local wait-for graphs plus cross-site edges representing remote wait relationships.

A distributed deadlock exists when there is a cycle in this global WFG.
The difficulty is that no single site holds the full graph.
Constructing and maintaining a consistent global snapshot of the WFG is expensive.
Worse, because of communication delays, a detection algorithm might observe edges that existed at different points in real time, potentially detecting cycles that never actually existed simultaneously.
These are called phantom deadlocks (or false deadlocks).

The three classical strategies for handling deadlocks apply in distributed systems too:

  1. Prevention: impose a total ordering on resources or use priority schemes (e.g., wound-wait, wait-die) to ensure cycles never form.
  2. Avoidance: use algorithms like Banker's algorithm, though this is essentially inapplicable in distributed settings because it requires each process to declare its maximum resource needs in advance and also requires complete, consistent global knowledge of current allocation state — a condition that cannot be maintained efficiently across sites.
  3. Detection and resolution: allow deadlocks to form, detect them, and break them by aborting one or more processes.

Distributed deadlock detection falls into the third category.

Classification of Detection Algorithms

Detection algorithms are typically classified along two axes: the topology of control and the mechanism of information propagation.

By Control Structure

  • Centralized: one designated coordinator collects WFG information from all sites, builds the global graph, and checks for cycles. Simple to reason about but creates a single point of failure and a bottleneck.
  • Distributed: all sites participate in the detection protocol cooperatively. No single site has the full picture; the algorithm works by propagating probes or dependency information along the edges of the WFG.
  • Hierarchical: sites are organized in a tree. Each internal node is responsible for detecting deadlocks that span its subtree. This is a compromise between centralized and fully distributed approaches.

By Detection Mechanism

  • Path-pushing: sites send their local WFG paths to other sites, which merge them with their own local paths to build progressively larger portions of the global WFG. Deadlock is detected when a site constructs a cycle from the merged paths.
  • Edge-chasing (probe-based): a special probe message is propagated along the edges of the WFG. If a probe returns to its initiator, a cycle exists. The Chandy-Misra-Haas algorithm is the canonical example.
  • Global state detection: use a consistent snapshot protocol (e.g., Chandy-Lamport) to capture a global state, then analyze it offline for cycles.

Algorithms

The Chandy-Misra-Haas Algorithm (Edge-Chasing)

diagram-2
The Chandy-Misra-Haas Algorithm (Edge-Chasing)

This is the most widely cited distributed deadlock detection algorithm for the AND model, where a process is blocked only when all of its outstanding requests are unsatisfied.
The algorithm works by propagating probe messages along wait-for edges across site boundaries.

Model

  • Process $P_i$ at site $S$ is waiting for process $P_j$ at site $T$.
  • A probe is a triple $(i, j, k)$ meaning: "process $P_i$ initiated this deadlock detection; this probe was most recently forwarded by $P_j$ to $P_k$." In the initiation step, both the initiator and the first sender are $P_i$ itself, so the initial probe has the form $(i, i, j)$.

Steps

1. Initiation:
   When process P_i suspects it is deadlocked (it has been
   blocked for some threshold), it sends probe(i, i, j) to
   each process P_j that it is waiting for.
   If P_j is on the same site, the probe is forwarded
   internally; if on a different site, it is sent as a message.

2. Propagation:
   When process P_k receives probe(i, j, k):
     a. If P_k is currently blocked (waiting for other processes),
        AND P_k has not already forwarded a probe for initiator i:
          Mark that P_k has now propagated for i.
          For each process P_m that P_k is waiting for:
            Send (or forward internally) probe(i, k, m).
     b. If P_k is not blocked, or has already propagated
        for initiator i, discard the probe.

3. Detection:
   If process P_i receives probe(i, *, i), i.e., the initiator
   field matches itself, then a cycle exists in the WFG.
   P_i declares deadlock.

4. Resolution:
   The deadlock is resolved by aborting one of the processes
   in the cycle. A common strategy: abort the process with
   the lowest priority or highest cost to restart.

Correctness Properties

  • Phantom deadlock resistance: The algorithm significantly reduces phantom deadlocks compared to path-pushing or centralized approaches. Probes propagate only along active wait-for edges: if a process is no longer blocked when a probe arrives, it discards the probe, terminating that chain. However, because probe propagation and edge release are asynchronous, there remains a theoretical possibility of a completed probe cycle reflecting edges that did not all coexist simultaneously. In practice, this race is narrow, and the algorithm is considered highly reliable for the AND model; the original CMH paper provides a careful proof of conditions under which the algorithm is sound.
  • Liveness: If a deadlock persists long enough for the probe to traverse the full cycle, it will be detected.
  • Message complexity: in the worst case, $O(e)$ probe messages per detection round, where $e$ is the number of edges in the WFG. Summed across all $n$ possible initiators, the total is $O(n \cdot e)$, which in dense graphs approaches $O(n^3)$ but is often written as $O(n^2)$ for sparse graphs where $e = O(n)$. In practice, probes die quickly along non-deadlocked paths.

The OR Model

In the OR model, a process is unblocked as soon as any one of its outstanding requests is satisfied (it needs one of several resources, not all of them).
The AND-OR model generalizes both.
Detection in the OR model is substantially harder: a single satisfied request can unblock a process, invalidating what appeared to be a dependency chain.
The original Chandy-Misra-Haas paper addresses the OR model with a distinct algorithm — an important part of the paper's contribution — that requires more complex bookkeeping.
Probes must carry additional information to track which requests remain outstanding, and a process can only be considered part of a deadlock cycle if none of its requests have been or will be satisfied.
Correctness in the OR model is therefore more subtle, and the OR-model algorithm is less widely deployed in practice than its AND-model counterpart.

Phantom Deadlocks

Phantom deadlocks are a critical concern.
Consider three processes, $P_1$, $P_2$, $P_3$, on three different sites.
Suppose $P_1 \rightarrow P_2$ (meaning $P_1$ waits for $P_2$), and $P_2 \rightarrow P_3$.
Now $P_2$ releases its dependency on $P_3$ and instead begins waiting for $P_1$.
A detection algorithm might observe the old edge $P_2 \rightarrow P_3$ and the new edge $P_2 \rightarrow P_1$ at different times, constructing a graph with edges that never coexisted, and falsely conclude that a cycle exists.

Probe-based algorithms like Chandy-Misra-Haas are designed to minimize this risk because probes propagate along live edges and are discarded when a process is no longer blocked.
Path-pushing and centralized algorithms are significantly more susceptible to phantom deadlocks unless they use consistent global snapshots, because they assemble the WFG from information collected at different real-time instants.

Practical Considerations

Performance and Overhead

Deadlock detection is not free.
Probe messages consume network bandwidth.
Centralized approaches create hotspots.
The frequency of detection (periodic vs. continuous) is a design knob.
In many real systems, deadlocks are rare, so running detection too aggressively wastes resources.
A common approach is to trigger detection only after a process has been waiting longer than a configurable timeout.

Deadlock Resolution

Detecting the deadlock is only half the problem.
You must also resolve it by aborting at least one process in the cycle.
Choosing which process to abort (the "victim") involves minimizing the cost of lost work.
In database systems, this typically means aborting the youngest transaction (the one with the least work invested).
Care must be taken to avoid starvation, where the same process is repeatedly chosen as the victim.

Timeouts as a Pragmatic Alternative

Many production distributed systems (including most distributed databases) do not implement formal deadlock detection at all.
Instead, they use timeouts: if a transaction is blocked for longer than a threshold, it is aborted.
This is simple, has no message overhead for detection, and handles not only deadlocks but also other liveness failures (crashed nodes, lost messages).
The downside is that the timeout must be tuned.
Too short, and you abort transactions that were merely slow.
Too long, and deadlocked transactions waste resources while waiting.

Google's Spanner, CockroachDB, and many other systems use variants of wait-die or wound-wait prevention schemes combined with timeouts rather than pure detection.

Relationship to Distributed Transactions

Deadlock detection is most commonly discussed in the context of distributed transaction processing, where two-phase locking can create cross-site wait dependencies.
Systems using optimistic concurrency control or multi-version concurrency control (MVCC) with snapshot isolation can avoid many deadlock scenarios by reducing lock contention.
Under pure MVCC where writers do not block readers (and vice versa), conflicts are typically resolved by aborting one of the conflicting transactions immediately rather than waiting, which structurally prevents the circular wait condition.
However, systems that combine MVCC with explicit locking for certain operations (e.g., SELECT FOR UPDATE) can still experience deadlocks.

Key Points

  • A distributed deadlock is a cycle in the global wait-for graph, which is partitioned across sites with no single node holding the complete picture.
  • Detection algorithms are classified as centralized, distributed, or hierarchical, and use mechanisms such as edge-chasing, path-pushing, or global snapshots.
  • The Chandy-Misra-Haas edge-chasing algorithm detects deadlocks by propagating probe messages along wait-for edges; a probe returning to its initiator confirms a cycle. The initial probe $(i, i, j)$ has the initiator $P_i$ as both the originator and first sender.
  • Phantom deadlocks (false positives caused by observing stale state) are a key correctness challenge. Probe-based algorithms significantly reduce them because probes die when a receiving process is no longer blocked, though asynchrony means the risk is not entirely eliminated.
  • Most production distributed systems use deadlock prevention (wound-wait, wait-die) or simple timeouts instead of formal detection algorithms, trading theoretical precision for operational simplicity.
  • Deadlock resolution requires choosing a victim process to abort, balancing the cost of lost work against the need to make progress, and must guard against starvation of repeatedly victimized processes.
  • The AND model and OR model of process blocking require fundamentally different detection approaches, with the OR model being significantly more complex due to the need to track partial satisfaction of requests.

References

K. M. Chandy, J. Misra, and L. M. Haas. "Distributed Deadlock Detection." ACM Transactions on Computer Systems, 1(2):144-156, 1983.

M. Singhal. "Deadlock Detection in Distributed Systems." IEEE Computer, 22(11):37-48, November 1989.

A. K. Elmagarmid. "A Survey of Distributed Deadlock Detection Algorithms." ACM SIGMOD Record, 15(3):37-45, 1986.

G. Coulouris, J. Dollimore, T. Kindberg, and G. Blair. "Distributed Systems: Concepts and Design." 5th Edition, Addison-Wesley, 2011.

Newsletter

Signal
over noise.

Distributed systems deep-dives, delivered once a week. Consensus, infrastructure, and the architecture that scales.

You will receive Distributed Systems Weekly.