問題描述
我正在運行以下 MySQL UPDATE
語句:
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
我沒有使用事務,為什么會出現此錯誤?我什至嘗試重新啟動我的 MySQL 服務器,但沒有幫助.
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.
該表有 406,733 行.
The table has 406,733 rows.
推薦答案
您正在使用事務;autocommit 不會禁用事務,它只是讓它們在語句結束時自動提交.
You are using a transaction; autocommit does not disable transactions, it just makes them automatically commit at the end of the statement.
發生的情況是,某個其他線程在某條記錄上持有記錄鎖(您正在更新表中的每條記錄!)太長時間了,并且您的線程超時了.
What is happening is, some other thread is holding a record lock on some record (you're updating every record in the table!) for too long, and your thread is being timed out.
您可以通過發布一個查看更多活動詳情
You can see more details of the event by issuing a
SHOW ENGINE INNODB STATUS
在事件之后(在 SQL 編輯器中).理想情況下,在安靜的測試機器上執行此操作.
after the event (in SQL editor). Ideally do this on a quiet test-machine.
這篇關于獲取“超出鎖定等待超時;嘗試重新啟動事務"即使我沒有使用交易的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!