Ruby: SQLite3::BusyException: database is locked:

后端 未结 18 1048
感动是毒
感动是毒 2020-11-28 23:29

Ran into this error message whilst developing tonight: SQLite3::BusyException: database is locked:

I have two models:

  • Podcasts have many
18条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 00:29

    For anyone else encountering this issue with SQLite locking in development when a Rails console is open, try this:

    Just run the following:

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

    For me anyway, it appears to clear any transaction that the console was holding onto and frees up the database.

    This is especially a problem for me when running delayed_job, which seems to fail at closing the transaction quite often.

提交回复
热议问题