Koed00 / django-q

A multiprocessing distributed task queue for Django
https://django-q.readthedocs.org
MIT License
1.83k stars 284 forks source link

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

Open igalci opened 3 years ago

igalci commented 3 years ago

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?

maerteijn commented 2 years ago

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.