Skip to content

Concurrency issues on SQLite #33

@RealOrangeOne

Description

@RealOrangeOne

SQLite doesn't support select_for_update, which is a key component of the database worker to ensure that a task is only picked up by a single database worker.

In Django 5.1, it's possible to change how the transactions are created. If transactions are created using EXCLUSIVE, this solves the concurrency issues, although increases the risk of locking errors (something we already work around with a retry, but it can reduce throughput). Therefore, without EXCLUSIVE, the task semantic changes from "at most once" to non-deterministic "zero or more times", which is at best unhelpful and at most a great source of confusion and complexity.

I see 2 possible solutions for this:

  1. Require that EXCLUSIVE transactions be used if SQLite is in a system check, and prevent usage without it
  2. Backport the functionality into django-tasks. This is far more complex, but it allows users of Django 4.2 and 5.0 to use SQLite.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdatabase-backendIssues relating to the database backend

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions