Concurrency

Deadlock

Two or more transactions wait on each other forever.


In plain terms

Detected by cycle-finding in a wait-for graph; resolved by aborting the youngest transaction. Postgres detects deadlocks every 1 second by default.

Origin

Coffman, Elphick, and Shoshani identified the four necessary conditions in 1971. Lock-ordering and timeout-based detection are the universal workarounds.

Where it shows up in production
  • PostgreSQL deadlock detector Runs every 1 second by default; aborts one transaction in the cycle.
  • MySQL InnoDB Same — periodic wait-for-graph scan; younger transaction loses.
  • Java thread dumps jstack identifies lock cycles directly; standard incident-debugging tool.
Sources & further reading
Found this useful?