🦍

aurora mysqlでdeadlockエラーが出るがプロセスkillできないとき

2021/06/24に公開

結論

インスタンスを再起動すればよい

環境

エンジンバージョン
5.7.mysql_aurora.2.07.4(mysql 5.7.12)

現象

処理中にDBをダウンさせたので後続の処理でdeadlockエラーが出た

ERROR 1213 (40001) at line 24: Deadlock found when trying to get lock; try restarting transaction

ぐぐると大抵プロセスを探してkillしろと書かれている
こんなかんじ↓

https://libitte.hatenablog.jp/entry/20141129/1417254010

しかし SHOW ENGINE INNODB STATUS; で該当のthread idを見つけてkillしてもエラーになった

kill xxx;
[HY000][1094] Unknown thread id: xxx

これでも同じ

CALL mysql.rds_kill(xxx);
[HY000][1094] Unknown thread id: xxx

そもそも show full processlist; を見ても該当のidがないのである(´~`)

原因と対処

There is no way to clear the LATEST DETECTED DEADLOCK section in SHOW ENGINE INNODB STATUS unfortunately. The query has already been killed by the deadlock detector, so there's nothing you can KILL. The only way to reset that information is to restart the server.

No properly written software should continuously alert due to the presence of something in that output.

https://stackoverflow.com/questions/21573684/mysql-innodb-deadlock-how-to-remove-old-event

クエリは既にデッドロック検出器によってキルされているので、キルできるものはなく、
リセットするには、サーバを再起動するしかない、と書かれている
Thank you jeremycole!

まさにこの状態だったので再起動したところ、
もう SHOW ENGINE INNODB STATUS;LATEST DETECTED DEADLOCK の項は出てこなくなり、後続の処理が動くようになった

FYI

同じ現象のひと

https://living-sun.com/ja/mysql/572334-why-can39t-i-kill-a-specific-thread-query-in-mysql-mysql-innodb-deadlock-kill.html

Discussion