Skip to content

perf: enable SQLite WAL journal mode and 5s busy timeout#667

Open
neuron-tech-ai wants to merge 1 commit into
jamiepine:mainfrom
neuron-tech-ai:perf/sqlite-wal-mode
Open

perf: enable SQLite WAL journal mode and 5s busy timeout#667
neuron-tech-ai wants to merge 1 commit into
jamiepine:mainfrom
neuron-tech-ai:perf/sqlite-wal-mode

Conversation

@neuron-tech-ai
Copy link
Copy Markdown

The default SQLite journal mode (DELETE/rollback) serializes all reads and writes — a write blocks all readers until it commits. Under concurrent API load (e.g., a generation in progress while the UI polls for updates), this produces "database is locked" errors.

WAL (Write-Ahead Logging) allows concurrent readers without blocking writers. Also adds a 5-second busy timeout so brief lock contention retries gracefully instead of immediately erroring.

Standard practice for SQLite in any multi-reader application.

Switch from the default DELETE/ROLLBACK journal to WAL so concurrent
readers (SSE status polls, history queries) are not blocked while the
generation worker holds a write transaction.  Set a 5-second busy
timeout to eliminate "database is locked" errors under brief write
contention.

Both PRAGMAs are applied via a custom creator function so every
connection in the pool gets the settings at open time, not just the
first one.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Warning

Rate limit exceeded

@neuron-tech-ai has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 9 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 93dfd7a8-4e35-4ea9-ad6c-c4410efb6c96

📥 Commits

Reviewing files that changed from the base of the PR and between b35b909 and ee8eb3a.

📒 Files selected for processing (1)
  • backend/database/session.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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