dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Glossary/Deadlock & Lock Wait Timeout
Deadlock & Lock Wait TimeoutConcurrency & MVCC

Deadlock Detection & Lock Wait Timeout Management

A cyclical dependency where two or more transactions indefinitely block each other holding mutually requested locks (Deadlock) or exceed the configured lock wait threshold (Timeout).

Internal Architecture Breakdown

InnoDB actively inspects lock wait-for graphs to detect cyclic deadlocks instantly. Upon detection, it identifies the transaction with the fewest modified rows as the victim, issues an automatic rollback, and returns error 1213.

For unresolvable row locks, innodb_lock_wait_timeout defaults to 50 seconds; tuning this to 2-5 seconds prevents cascading connection exhaustion during application blocking storms.

Production Inspection Queries

MySQL
SHOW ENGINE INNODB STATUS\G; -- 'LATEST DETECTED DEADLOCK'
SHOW VARIABLES LIKE 'innodb_lock_wait_timeout';