Cycle Detection
An algorithm to detect deadlock by searching for cycles in the graph of transaction wait dependencies.
Each locked transaction that's waiting for another transaction to release a resource is represented as a directed edge in a graph. A cycle in this graph means transaction A is waiting for B, B is waiting for C, and C is waiting for A — a deadlock. The database can then choose to abort one transaction to break the cycle and unblock the others.
Cycle detection is reactive — it finds deadlock after it occurs — unlike deadlock prevention which tries to avoid it upfront. The approach is slow for large systems with many transactions but works well for small to medium systems where lock conflicts are rare. IBM's early database systems and CODASYL databases relied on this technique.