When I run SHOW ENGINE INNODB STATUS\G
, I can see this timestamp
------------------------
LATEST DETECTED DEADLOCK
------------------------
121118 17:14:31
Questions
- Any idea how long Deadlock details/info holds in innodb status page ?
- After how long does it refreshes or clears the recent deadlock info?
- Any way I can force to get the current status of Deadlocks?
Regards,
Mannoj
Best Answer
The first thing you must look for is the setting for
innodb_lock_wait_timeout
.Suppose you run this
SHOW VARIABLES LIKE 'innodb_lock_wait_timeout';
and getAt the very least, you should rightly expect a newly detected deadlock on a busy DB server every 50 seconds.
InnoDB cannot detect deadlock under two conditions:
LOCK TABLES
is explicit executedThese two conditions are usually self-inflicted and relatively easy to find. Setting the
innodb_lock_wait_timeout
would be the usual workaround.However, there is a one boobytrap you need to be aware of. It is possible for
SELECT
queries to create row-level locks. Many developers are not aware of this quirky behavior. In fact, according to the MySQL Documentation:I discussed this back on Aug 08, 2011 : Are InnoDB Deadlocks exclusive to INSERT/UPDATE/DELETE?
RECOMMENDATIONS
deadly embrace
situations--lock-tables
and--single-transaction
mixed.With these recommendations, you can hopefully assure that the deadlock status in
SHOW ENGINE INNODB STATUS\G
should be updated with a degree of regularity.