We have a problem where our ORM is locking more tables than I'd expect. This is causing deadlock on our production system which I'm struggling to diagnose.
I can see, using either SHOW ENGINE INNODB STATUS
or by using the innotop tool the top 10 locks, but I'm unable to see the rest.
Here's the head and tail of an example output from SHOW ENGINE INNODB STATUS
:
--TRANSACTION 1832883, ACTIVE 1728 sec
29 lock struct(s), heap size 3520, 14 row lock(s), undo log entries 10
...
10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS
How can I view the locks beyond the first 10?
Perconda has the innodb_show_locks_held
variable – is there an alternative for MySQL? I'm using MySQL 5.7 in development if that's relevant.
Thanks,
Ed
Best Answer
I recommend using the SYS schema that ships with MySQL 5.7. This will show you lock waits (more useful than locks) in a pretty easy to diagnose way: