fix: set busy_timeout before journal_mode=WAL in _enable_wal#24
Open
kenyonxu wants to merge 1 commit into
Open
fix: set busy_timeout before journal_mode=WAL in _enable_wal#24kenyonxu wants to merge 1 commit into
kenyonxu wants to merge 1 commit into
Conversation
PRAGMA busy_timeout must be set before PRAGMA journal_mode=WAL so the WAL pragma uses the configured timeout (10s) instead of the default (5s). If another process holds a write lock, the old ordering could fail with SQLITE_BUSY after only 5 seconds.
varun369
added a commit
that referenced
this pull request
May 18, 2026
Previously _enable_wal() set journal_mode=WAL before busy_timeout, causing the WAL pragma to use SQLite's default 5-second busy timeout instead of the configured 10 seconds. If another process held a write lock during WAL initialization, the connection could fail with SQLITE_BUSY after only 5 seconds instead of the intended 10. Swap the two PRAGMA calls so busy_timeout is set first, ensuring the WAL pragma uses the configured timeout. Author: kenyonxu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_enable_wal()setsPRAGMA journal_mode=WALbeforePRAGMA busy_timeout, causing the WAL pragma to use SQLite's default 5-second busy timeout instead of the configured 10 seconds. If another process holds a write lock during WAL initialization, the connection can fail withSQLITE_BUSYafter only 5 seconds instead of the intended 10.Fix
Swap the two PRAGMA calls so
busy_timeoutis set first, ensuring the WAL pragma uses the configured timeout.Test
Added
test_enable_wal_busy_timeout_before_walthat verifies the PRAGMA execution order.