58
55

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

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するようにしてギャップロックのデッドロックを解消しました。

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

58
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
58
55

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?