Comments on: How to find out who is locking a table in MySQL http://www.xaprb.com/blog/2006/07/31/how-to-analyze-innodb-mysql-locks/ Stay curious! Fri, 10 May 2013 18:25:19 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Doru http://www.xaprb.com/blog/2006/07/31/how-to-analyze-innodb-mysql-locks/#comment-19448 Doru Thu, 23 Jun 2011 19:10:22 +0000 http://www.xaprb.com/blog/?p=158#comment-19448 To see which MYISAM tables are locked try ‘show open tables’

See this article: http://stackoverflow.com/questions/2499976/detecting-locked-tables-mysql-locked-by-lock-table
and the manual: http://dev.mysql.com/doc/refman/5.0/en/show-open-tables.html

]]>
By: APZ http://www.xaprb.com/blog/2006/07/31/how-to-analyze-innodb-mysql-locks/#comment-17938 APZ Thu, 04 Mar 2010 16:42:55 +0000 http://www.xaprb.com/blog/?p=158#comment-17938 Hi,

Nice article!

Do you have any tips for diagnosing deadlocks where there appears to be only one active process?

]]>
By: Levi http://www.xaprb.com/blog/2006/07/31/how-to-analyze-innodb-mysql-locks/#comment-1397 Levi Tue, 08 Aug 2006 23:44:04 +0000 http://www.xaprb.com/blog/?p=158#comment-1397 SHOW PROCESSLIST; also helps a lot.

In particular, it’s the only way I’ve found to identify MyISAM implicit locks: MyISAM doesn’t support transactions, and prioritises updates over reads. To avoid inconsistent data, reads can cause implicit table locks.

Where this matters is a situation like the following:

SELECT * from bigTable WHERE (complicatedQueryConditions);
UPDATE bigTable SET someField=someField+1 WHERE id=1;

The SELECT will lock out the UPDATE until it finishes, and because updates are prioritised over reads and new selects will in turn be waiting for the UPDATE to finish.

If the SELECT takes eg 30 seconds, in effect every access to that table will be waiting on the SELECT. In such a situation, SHOW PROCESSLIST will be able to show you which query is not in a LOCKED state, and you can identify the evil query quite quickly.

]]>