Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there anyway to show all the locks that are active in a mysql database?

share|improve this question
add comment

4 Answers

up vote 15 down vote accepted

See Marko's link for InnoDB tables and the caveats.

For MyISAM, there isn't a dead easy "this is the offending query" solution. You should always start with a processlist. But be sure to include the full keyword so that the printed queries aren't truncated:

SHOW FULL PROCESSLIST;

This will show you a list of all current processes, their SQL query and state. Now usually if a single query is causing many others to lock then it should be easy to identify. The affected queries will have a status of Locked and the offending query will be sitting out by itself, possibly waiting for something intensive, like a temporary table.

If it's not obvious then you will have to use your powers of SQL deduction to determine which piece of offending SQL may be the cause of your woes.

share|improve this answer
add comment

Using this command

SHOW PROCESSLIST

will show all process currently running, including process that has acquired lock on tables.

share|improve this answer
add comment

AFAIK there's still no native way in MYSQL, but I use innotop. It's free and has plenty of other functionality as well.

Also see this link for more information on using the innotop tool.

share|improve this answer
add comment
show open tables where In_Use > 0 ;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.