Buy Percona ServicesBuy Now!

Count InnoDB Deadlocks

When running a transactional application you have to live with deadlocks. They are not problematic as long as they do not occur too frequently. The standard SHOW INNODB STATUS gives information on the latest deadlocks but it is not very useful when you want to know the total number of deadlocks or the number of deadlocks per unit of time.

This change adds a status variable that keeps track of the number of deadlocks since the server startup, opening the way to a better knowledge of your deadlocks.

This feature was provided by Eric Bergen under BSD license (see InnoDB Deadlock Count Patch).

It adds a new global status variable (innodb_deadlocks) showing the number of deadlocks.*

You can use it with SHOW GLOBAL STATUS, e.g.:

mysql> SHOW GLOBAL STATUS LIKE 'innodb_deadlocks';
| Variable_name    | Value |
| innodb_deadlocks | 323   |


| 323            |

A deadlock will occur when at least two transactions are mutually waiting for the other to finish, thus creating a circular dependency that lasts until something breaks it. InnoDB is quite good at detecting deadlocks and generally returns an error instantly. Most transactional systems have no way to prevent deadlocks from occurring and must be designed to handle them, for instance by retrying the transaction that failed.

Version Specific Information

Status Variables

One new status variable was introduced by this feature.

variable Innodb_deadlocks
Variable Type:LONG
Visit Percona Store

General Inquiries

For general inquiries about our open source software and database management tools, please send us your question and someone will contact you.