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.