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 AgentandThomas Klemm committed 2026-10-07 18:53:19 +00:00
1 parent 6e312c6028
commit 88acc4e026
7 files changed
+389 -1

No files matched your search

@@ -0,0 +1,10 @@
# Start a checkpoint contender in console, runner, rake and other non-Puma writers.
# Puma skips this path: config/puma.rb and config/puma_dev.rb start after the
# correct process is chosen (worker boot vs single-process), so the master that
# only forks workers never holds the lock alone. Resque starts after_prefork.
Rails.application.config.after_initialize do
next if Rails.env.test?
next if defined?(Puma::CLI)
SqliteWalCheckpoint.start
end