Checkpoint SQLite WAL off the request thread safely

Disable wal_autocheckpoint and run PASSIVE checkpoints from one elected
writer process. Contenders start in console/rake (initializer), Puma
workers (including WEB_CONCURRENCY=auto), and Resque children, with
failover, capped error backoff, and tests for lock takeover.

Co-authored-by: Thomas Klemm <github@tklemm.eu>
This commit is contained in:
Cursor Agent
2026-10-07 18:53:19 +00:00
parent 6e312c6028
commit 88acc4e026
7 changed files with 389 additions and 1 deletions
+4
View File
@@ -9,6 +9,10 @@ default: &default
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 10 } %>
timeout: 5000
default_transaction_mode: immediate
# Checkpoint on a background connection instead (SqliteWalCheckpoint). Every
# non-test writer process runs a contender so this is never left without one.
pragmas:
wal_autocheckpoint: 0
development:
primary: