Skip to content

fix: set busy_timeout before journal_mode=WAL in _enable_wal#24

Open
kenyonxu wants to merge 1 commit into
qualixar:mainfrom
kenyonxu:fix/wal-busy-timeout-ordering
Open

fix: set busy_timeout before journal_mode=WAL in _enable_wal#24
kenyonxu wants to merge 1 commit into
qualixar:mainfrom
kenyonxu:fix/wal-busy-timeout-ordering

Conversation

@kenyonxu
Copy link
Copy Markdown

Summary

_enable_wal() sets PRAGMA journal_mode=WAL before PRAGMA 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 with SQLITE_BUSY after only 5 seconds instead of the intended 10.

Fix

Swap the two PRAGMA calls so busy_timeout is set first, ensuring the WAL pragma uses the configured timeout.

Test

Added test_enable_wal_busy_timeout_before_wal that verifies the PRAGMA execution order.

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
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