FreeNo sign-up.

MySQL Deadlock Analyzer

Paste the LATEST DETECTED DEADLOCK section of SHOW ENGINE INNODB STATUS. dbCove AI explains the locks on both sides and gives the change that stops it.

How to get the deadlock

The last deadlock

The LATEST DETECTED DEADLOCK section of:

SHOW ENGINE INNODB STATUS;
Every deadlock

Write each one to the error log, not only the last:

SET GLOBAL innodb_print_all_deadlocks = ON;
Which transactions

The locks held and waited for right now (MySQL 8.0):

SELECT * FROM performance_schema.data_lock_waits;

What it looks for in an InnoDB deadlock

Gap and next-key locks

Range locks under REPEATABLE READ that block inserts into the same gap.

Insert intention

Two inserts each waiting on the other's gap lock: the classic booking table deadlock.

Lock order

Two transactions that update the same rows in opposite order.

Secondary and primary index

A lookup through a secondary index meeting an update of the clustered record.

The rolled back transaction

Which one InnoDB rolled back, and the statement it ran.

Read nextMySQL lock wait timeout: find the blocking transaction

This was one deadlock. dbCove catches every one.

On your own databases dbCove records every deadlock with the statements on both sides, groups them by pattern, and its AI explains them as they happen. Free for 2 databases of each engine.

Questions

Is what I paste kept?

It is sent to our AI provider to be explained and kept by us for up to 12 months to improve the tools; the AI provider does not keep it or train on it. Remove passwords and personal data before you paste.

Which transaction was rolled back?

The one named in WE ROLL BACK TRANSACTION. InnoDB picks the transaction that is cheaper to undo, by rows changed and locked.

Does READ COMMITTED stop it?

Often, for gap lock deadlocks, because searches then take no gap locks. It changes what a repeated read can see, so the answer says when it is safe and what to do when it is not.

Which versions does it read?

MySQL 5.7 and 8.x, including Amazon RDS for MySQL, Aurora MySQL and Azure Database for MySQL.