LoginSignup
59
55

MySQLのBULK INSERTでデッドロックを回避する

Last updated at Posted at 2015-04-05

TL;DR

ActiveRecord::StatementInvalid: Mysql2::Error: Deadlock found when trying to get lock; try restarting transaction: INSERT INTO books (id,name) VALUES ...

というエラーが出たので、ソートしてからBULK INSERTするようにしてギャップロックのデッドロックを解消しました。

詳しい原因や対応などについては、以下のブログ記事をご覧ください。

59
55
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
59
55