Mysql – Disable InnoDB deadlock detection

deadlockinnodbMySQLmysql-5.7

I would like to disable InnoDB dead-lock detection and automatic rollback, as per the requirement we like to rely on innodb_lock_wait_timeout (because of heavy concurrency).

The lock wait timeout value does not apply to deadlocks when
innodb_deadlock_detect is enabled (the default) because InnoDB detects
deadlocks immediately and rolls back one of the deadlocked
transactions. When innodb_deadlock_detect is disabled, InnoDB relies
on innodb_lock_wait_timeout for transaction rollback […]

How can we achieve the above in MySQL 5.7.13? I couldn't find any variable innodb_deadlock_detect.

Best Answer

Yes, you can do it. Be sure to keep innodb_lock_wait_timeout reasonably low, for example, 2 seconds. Deadlocks that last for 2 seconds are completely harmless, if they are rare (and usually they are very rare). Remind developers to avoid long transactions, and avoid foreign keys ON ... CASCADE (because they propagate locks, making deadlocks more likely).

Of course I am assuming that you can keep a very low value for those timeouts. But can you? I don't know your workload but, for example, a statement may lock some rows for 10 seconds every hour. In such cases, can you afford a low timeout? If not, then everything I wrote above does not apply to you.