Conversation
…USY race When two processes share the same qmd sqlite store — for example a long-running MCP daemon and a `qmd` CLI invocation (often driven from a short-interval cron) — the second writer hits SQLITE_BUSY immediately and aborts, because sqlite's default behaviour is to error rather than wait on a locked database. Set PRAGMA busy_timeout = 10000 (10s) in openDatabase() so every connection qmd opens wait-and-retries for up to 10 seconds before giving up. That covers the typical write window of either side and lets concurrent operations succeed without external coordination. This is the standard sqlite pattern for short-lived multi-process contention. The pragma is set at the single openDatabase() choke point, so it applies uniformly under both bun:sqlite and better-sqlite3.
Contributor
Author
|
Closing as superseded by upstream. Since this PR was opened,
That covers the SQLITE_BUSY race this PR was targeting and then some, so there's nothing left for this change to add. Thanks! |
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.
What
Sets
PRAGMA busy_timeout = 10000(10s) on every SQLite connection qmd opens, at the singleopenDatabase()choke point insrc/db.ts.Why
When two processes share the same qmd store — e.g. a long-running MCP daemon and a
qmdCLI invocation (often driven from a short-interval cron) — the second writer hitsSQLITE_BUSYimmediately and aborts, because SQLite's default is to error rather than wait on a locked database:busy_timeoutmakes SQLite wait-and-retry for up to the timeout before giving up — the standard pattern for short-lived multi-process contention. 10s comfortably covers the typical write window of either side.Details
openDatabase(), the only place qmd creates a connection (verified — the sole other open site routes through it). Applies uniformly under bothbun:sqliteandbetter-sqlite3.tsc --noEmitclean.