简体   繁体   English

找出什么锁定了MySQL InnoDB表行

[英]Find out what is locking a MySQL InnoDB table-row

I use a database with an InnoDB-table. 我使用带有InnoDB表的数据库。 When I try to update a row, I get the "ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction" message, which I don't get on any other row (that I've tried). 当我尝试更新一行时,出现“错误1205(HY000):超出了锁定等待超时;尝试重新启动事务”消息,但没有出现在其他任何行上(我已经尝试过)。

How can I debug that? 我该如何调试?

SHOW PROCESSLIST;

is only yielding sleeping processes and because it's an InnoDB table, SHOW TABLE STATUS is basically useless (seems to work only for MyISAM tables). 仅产生休眠进程,并且因为它是InnoDB表,所以SHOW TABLE STATUS基本上是无用的(似乎仅适用于MyISAM表)。

SHOW ENGINE INNODB STATUS 显示引擎的INNODB状态

also does not contain anything useful; 也不含任何有用的东西; the LATEST DETECTED DEADLOCK section contains two transactions from 3 days ago that no longer exist (thread IDs no longer appear in SHOW PROCESSLIST) and no longer seem relevant. “最近检测到的死锁”部分包含三天前不再存在的两个事务(线程ID不再出现在SHOW PROCESSLIST中)并且看起来不再相关。

Is there any way to get to know what query caused the problem? 有什么方法可以了解导致问题的查询吗? Also I would love to see the current locks on InnoDB tables, what is locking what right now - and not three days ago. 我也很想看到InnoDB表上的当前锁,什么锁在现在-而不是三天前。

Have you checked the error log file of mysql? 您检查过mysql的错误日志文件了吗? Maybe there is more detail to which transaction it is that failed. 也许对失败的事务有更多的细节。

To show all tables that are in use, simply execute this syntax 要显示所有正在使用的表,只需执行以下语法

SHOW OPEN TABLES WHERE IN_Use=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM