問題描述
我正在運(yùn)行以下 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
我沒有使用事務(wù),為什么會(huì)出現(xiàn)此錯(cuò)誤?我什至嘗試重新啟動(dòng)我的 MySQL 服務(wù)器,但沒有幫助.
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.
推薦答案
您正在使用事務(wù);autocommit 不會(huì)禁用事務(wù),它只是讓它們?cè)谡Z句結(jié)束時(shí)自動(dòng)提交.
You are using a transaction; autocommit does not disable transactions, it just makes them automatically commit at the end of the statement.
發(fā)生的情況是,某個(gè)其他線程在某條記錄上持有記錄鎖(您正在更新表中的每條記錄!)太長(zhǎng)時(shí)間了,并且您的線程超時(shí)了.
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.
您可以通過發(fā)布一個(gè)查看更多活動(dòng)詳情
You can see more details of the event by issuing a
SHOW ENGINE INNODB STATUS
在事件之后(在 SQL 編輯器中).理想情況下,在安靜的測(cè)試機(jī)器上執(zhí)行此操作.
after the event (in SQL editor). Ideally do this on a quiet test-machine.
這篇關(guān)于獲取“超出鎖定等待超時(shí);嘗試重新啟動(dòng)事務(wù)"即使我沒有使用交易的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!