Skip to content

fix: set PRAGMA busy_timeout to prevent SQLITE_BUSY_RECOVERY errors#572

Open
SleepyGab wants to merge 1 commit intotobi:mainfrom
SleepyGab:fix/sqlite-busy-timeout
Open

fix: set PRAGMA busy_timeout to prevent SQLITE_BUSY_RECOVERY errors#572
SleepyGab wants to merge 1 commit intotobi:mainfrom
SleepyGab:fix/sqlite-busy-timeout

Conversation

@SleepyGab
Copy link
Copy Markdown

Summary

  • Set PRAGMA busy_timeout = 5000 in openDatabase() so SQLite retries for up to 5 seconds when another process holds the lock, instead of immediately failing with SQLITE_BUSY / SQLITE_BUSY_RECOVERY.

Context

When openclaw gateway manages multiple agents (e.g. main, coding, content), each agent spawns qmd update and qmd search on overlapping 5-minute timers. Without a busy timeout, concurrent access to the same SQLite index causes SQLITE_BUSY_RECOVERY errors at initializeDatabasePRAGMA 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

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