4
4

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 3 years have passed since last update.

SQLite3::BusyException: database is locked: エラー

Last updated at Posted at 2019-12-26

####環境:

Rails 5.1.7

####エラー内容:
SQLiteのカラムを少し変更してから、DBにフォームを送るとサーバー上で下記のようなエラー検出

ActiveRecord::StatementInvalid (SQLite3::BusyException: database is locked: INSERT INTO "budgets" ("budget_type", "price", "memo", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?)):

####エラー原因:
DB Browser for SQLite(SQLite管理ソフト)内でのデータ更新のし忘れ

####試したこと:

① ターミナルで rails c して

ActiveRecord::Base.connection.execute("BEGIN TRANSACTION; END;")

を打つ => 失敗

② config/database.yml内の、timeoutの値を5000から10000に変更 => 失敗
③ DB Browser for SQLite でDBを更新 => 成功

####考察:
データ矛盾を防ぐための排他制御によって専有ロックがかかったのかな(?)

4
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?