Getting “Lock wait timeout exceeded; try restartin

2019-01-01 07:48发布

I'm running the following MySQL UPDATE statement:

mysql> update customer set account_import_id = 1;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

I'm not using a transaction, so why would I be getting this error? I even tried restarting my MySQL server and it didn't help.

The table has 406,733 rows.

14条回答
只靠听说
2楼-- · 2019-01-01 08:29

Had this same error, even though I was only updating one table with one entry, but after restarting mysql, it was resolved.

查看更多
十年一品温如言
3楼-- · 2019-01-01 08:30

100% with what MarkR said. autocommit makes each statement a one statement transaction.

SHOW ENGINE INNODB STATUS should give you some clues as to the deadlock reason. Have a good look at your slow query log too to see what else is querying the table and try to remove anything that's doing a full tablescan. Row level locking works well but not when you're trying to lock all of the rows!

查看更多
永恒的永恒
4楼-- · 2019-01-01 08:30

Late to the party (as usual) however my issue was the fact that I wrote some bad SQL (being a novice) and several processes had a lock on the record(s) <-- not sure the appropriate verbiage. I ended up having to just: SHOW PROCESSLIST and then kill the IDs using KILL <id>

查看更多
浅入江南
5楼-- · 2019-01-01 08:30

This kind of thing happened to me when I was using php language construct exit; in middle of transaction. Then this transaction "hangs" and you need to kill mysql process (described above with processlist;)

查看更多
临风纵饮
6楼-- · 2019-01-01 08:33

Can you update any other record within this table, or is this table heavily used? What I am thinking is that while it is attempting to acquire a lock that it needs to update this record the timeout that was set has timed out. You may be able to increase the time which may help.

查看更多
不再属于我。
7楼-- · 2019-01-01 08:39

If you have nothing else running and its your own instance, I find it would be more efficient to just restart mysql

查看更多
登录 后发表回答