# Best way to monitor InnoDB locks

**URL:** <https://forums.percona.com/t/best-way-to-monitor-innodb-locks/1891>\
**Category:** Other MySQL® Questions\
**Created:** [September 10, 2012, 10:20am UTC](https://forums.percona.com/t/best-way-to-monitor-innodb-locks/1891 "2012-09-10T10:20:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IlKa](https://avatars.discourse-cdn.com/v4/letter/i/a9adbd/32.png) [@IlKa](https://forums.percona.com/u/IlKa)\
**Post date:** [September 10, 2012, 10:20am UTC](https://forums.percona.com/t/best-way-to-monitor-innodb-locks/1891/1 "2012-09-10T10:20:39Z")

</div>

Hello.

Our app is written on Java, connected to MySQL using JBDC and iBatis does ORM for us.

Sometimes we have locks: “Lock wait timeout exceeded; try restarting transaction”.

We can restart transaction but we really want to know which object been locked by which transaction.

We can use “SHOW INNODB STATUS” is case of such errors but we do not want to reinvent the wheel.

Probably there is a way to configure MySQL to log that fact?

---

<div class="post-metadata">

**Author:** ![scott.nemes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/scott.nemes/32/5_2.png) [@scott.nemes](https://forums.percona.com/u/scott.nemes)\
**Post date:** [September 10, 2012, 1:07pm UTC](https://forums.percona.com/t/best-way-to-monitor-innodb-locks/1891/2 "2012-09-10T13:07:55Z")

</div>

The data in “show (engine) innodb status” is your best bet. I would enable the innodb\_monitor (CREATE TABLE innodb\_monitor (a INT) ENGINE=INNODB; in the mysql database). That will continually output the InnoDB status to your error log, so you can then go back and review it for the time period in question after the fact.

---

<div class="post-metadata">

**Author:** ![IlKa](https://avatars.discourse-cdn.com/v4/letter/i/a9adbd/32.png) [@IlKa](https://forums.percona.com/u/IlKa)\
**Post date:** [September 12, 2012, 5:53am UTC](https://forums.percona.com/t/best-way-to-monitor-innodb-locks/1891/3 "2012-09-12T05:53:27Z")

</div>

Thanks!

I’ve enabled innodb monitor and general log. Will try to investigate locks:)
