mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 08:26:03 +00:00
refactor(settings): SQLite's WAL mode is an init_command
The operations app set PRAGMA journal_mode=WAL from a connection_created receiver because Django's SQLite OPTIONS had no init command; Django 5.1 added init_command, so the template sets it there and the receiver goes. The mode is stored in the database file, so existing databases keep it.
This commit is contained in:
parent
2e287f3a7f
commit
2440c9eaf7
2 changed files with 3 additions and 14 deletions
|
|
@ -161,9 +161,9 @@ else:
|
|||
"NAME": Path.joinpath(BASE_DIR, "db.sqlite3"),
|
||||
# IMMEDIATE takes the write lock when a transaction starts, so a
|
||||
# check-then-write cannot interleave with another process; timeout
|
||||
# is how long a writer waits for that lock (seconds). WAL is set
|
||||
# per connection by the operations app.
|
||||
"OPTIONS": {"transaction_mode": "IMMEDIATE", "timeout": 20},
|
||||
# is how long a writer waits for that lock (seconds). WAL lets the
|
||||
# worker and gunicorn read while one of them writes.
|
||||
"OPTIONS": {"transaction_mode": "IMMEDIATE", "timeout": 20, "init_command": "PRAGMA journal_mode=WAL"},
|
||||
# A file, not shared-cache memory: test threads and worker processes
|
||||
# open the same database, and shared-cache locks ignore the timeout.
|
||||
"TEST": {"NAME": os.getenv("WEBVIRTCLOUD_TEST_DB") or Path.joinpath(BASE_DIR, "test_db.sqlite3")},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue