django-q icon indicating copy to clipboard operation
django-q copied to clipboard

Why am I getting 'ERROR database is locked' with SQLite so often?

Open igalci opened this issue 3 years ago • 1 comments

I am using SQLite and I am often getting [Q] ERROR database is locked.

I already set the workers to 1 in settings to avoid multi-tasking, but it still seems to start the next task before ending the previous one.

I also set my SQLite database settings to have 'OPTIONS': {'timeout': 1000.0,} but it doesn't seem to have an effect.

So anyone knows how to stop simultaneous/async tasks and fix the database locking problem?

igalci avatar Sep 20 '21 20:09 igalci

SQLite isn't a database server but file based, so not suitable for multi-concurrency. Even if you put workers to 1, the django process needs access too so you'll always have more than one process accessing the same file. You should use a dedicated database server (Postgres / MySQL) for this to work.

maerteijn avatar Feb 01 '22 10:02 maerteijn