fix: set PRAGMA busy_timeout to prevent SQLITE_BUSY_RECOVERY errors#572
Open
fix: set PRAGMA busy_timeout to prevent SQLITE_BUSY_RECOVERY errors#572
Conversation
When multiple processes access the same index concurrently (e.g. openclaw gateway managing several agents, each spawning qmd update and search on overlapping timers), the database open can fail with SQLITE_BUSY_RECOVERY because no busy handler is configured — SQLite gives up immediately instead of waiting for the lock. Setting busy_timeout = 5000 lets SQLite retry for up to 5 seconds before returning SQLITE_BUSY errors.
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
PRAGMA busy_timeout = 5000inopenDatabase()so SQLite retries for up to 5 seconds when another process holds the lock, instead of immediately failing withSQLITE_BUSY/SQLITE_BUSY_RECOVERY.Context
When openclaw gateway manages multiple agents (e.g. main, coding, content), each agent spawns
qmd updateandqmd searchon overlapping 5-minute timers. Without a busy timeout, concurrent access to the same SQLite index causesSQLITE_BUSY_RECOVERYerrors atinitializeDatabase→PRAGMA journal_mode = WAL, which cascades as a misleading "does not support dynamic extension loading / set BREW_PREFIX" message (because the real error is re-thrown from the same try-catch block).This has been silently breaking qmd memory search since early April on affected setups — the gateway falls back to its builtin index and the qmd index goes stale.
Change
One-line PRAGMA in
src/db.ts:openDatabase()— applied before any other initialization so all database opens benefit.🤖 Generated with Claude Code