Skip to content

Configure SQLite pragmas to reduce database lock contention#263

Merged
eirvandelden merged 1 commit into
mainfrom
ai/configure-sqlite-production
Jul 5, 2026
Merged

Configure SQLite pragmas to reduce database lock contention#263
eirvandelden merged 1 commit into
mainfrom
ai/configure-sqlite-production

Conversation

@eirvandelden

Copy link
Copy Markdown
Owner

Summary

  • Set journal_mode: wal, synchronous: normal, temp_store: memory, cache_size: -20000, mmap_size: 128MB, and wal_autocheckpoint: 10000 on the shared default: anchor in config/database.yml so production and development share one source of truth (and any future Solid Queue/Cache/Cable databases inherit it automatically).
  • Lowered production/development timeout to 5000ms; test overrides with a 20000ms timeout, synchronous: off, and a 256MB mmap_size to tolerate parallel test-runner contention without slowing down disposable test writes.
  • Deliberately did not add a pragmas.busy_timeout — Rails' existing timeout: key already installs a GVL-friendly busy handler, and the native pragma would replace it with a GVL-blocking one, which is worse under threaded Puma.

Test plan

  • bin/rails runner confirms pragmas apply in both development and test environments
  • bin/rails test — 611 runs, 0 failures
  • Pre-push hooks (brakeman, bundler_audit, herb, rubocop) all clean

Set journal_mode, synchronous, temp_store, cache_size, and mmap_size
pragmas per environment (shared via the default anchor so production
and development stay in sync, and any future Solid Queue/Cache/Cable
databases inherit them automatically), with tighter busy timeouts and
looser durability settings in test to tolerate parallel test runs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@eirvandelden eirvandelden merged commit d67c18a into main Jul 5, 2026
4 checks passed
@eirvandelden eirvandelden deleted the ai/configure-sqlite-production branch July 5, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant