Deadlock detection
A concurrency control method where the system allows lock conflicts to arise, then periodically searches for cycles in the wait graph and aborts a transaction to break the deadlock.
Transaction A locks row 1 and waits for row 2 (locked by B). Transaction B locks row 2 and waits for row 1. Both wait forever — deadlock. Deadlock detection builds a "wait-for graph" and searches for cycles. Finding one, it kills a chosen transaction to break the cycle.
The opposite is deadlock prevention — design the lock order so cycles can't form. Detection is more common in practice because prevention is rigid. Detection costs CPU for the search, but only sometimes; prevention costs ordering discipline all the time. PostgreSQL and MySQL use detection.