Sqlite3::Busyexception

Ruby: SQLite3::BusyException: database is locked:

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.

SQLite3::BusyException

By default, sqlite returns immediatly with a blocked, busy error if the database is busy and locked. You can ask for it to wait and keep trying for a while before giving up. This usually fixes the problem, unless you do have 1000s of threads accessing your db, when I agree sqlite would be inappropriate.


// set SQLite to wait and retry for up to 100ms if database locked
sqlite3_busy_timeout( db, 100 );

SQLite3::BusyException: database is locked' Exception on upload via carrierwave

SQLite3 is a file-based database, and locking is little less advanced than a full fledged DB; I would only use it in a few users setting. Maybe you have opened the DB in a SQLite viewer or another process that is locking the DB at the same time?

There are plenty of suggestions in this thread: Ruby: SQLite3::BusyException: database is locked:

Rails: Locked DB? - SQLite3::BusyException:

Are you trying to do this while your Rails server is running?

Or have you tried to manually insert or delete rows on the table using tools like SQLite Database Browser?

Sqlite has a poor concurrency support and any action that throws the database off a little will throw Busy exception.

If the error continues to occur, and data you have in the database isn't that important, just drop the database and migrate again. The error should be gone.

SQLite3::BusyException error

The thing is, when the user hit the created method the method from_omniauth(auth) is checking if a user exists, if the user dosent exist its starting creating the user and grabbing all information from auth hash provided from Facebook. But before saving the user it calls the add_friends method, the user dosent exsist yet therefor the error!

So you have to save the user first and then call the add_friends method

And Sqlite3 is incapable of nested transactions!

cheers!



Related Topics



Leave a reply



Submit