Skip to content

Enable busy_timeout + foreign_keys for multi-writer safety#101

Open
Dmheath1 wants to merge 3 commits into
obra:mainfrom
Dmheath1:feat/wal-pragmas-for-multi-writer
Open

Enable busy_timeout + foreign_keys for multi-writer safety#101
Dmheath1 wants to merge 3 commits into
obra:mainfrom
Dmheath1:feat/wal-pragmas-for-multi-writer

Conversation

@Dmheath1
Copy link
Copy Markdown

@Dmheath1 Dmheath1 commented May 25, 2026

Multiple Claude Code sessions concurrently writing to the same SQLite store produces corruption. better-sqlite3 doesn't enable WAL by default (though this repo already set it). The PRAGMAs added here are standard for any multi-process SQLite:

  • `busy_timeout = 5000` — wait up to 5s for a lock before failing
  • `foreign_keys = ON` — restore FK enforcement after the sqlite-vec extension load path disables it

Applied to all three Database connection points: `src/db.ts` (main writer), `dist/mcp-server.js` (separate MCP-server writer that wasn't covered by the existing sync-cli lock), and `src/stats.ts` (readonly connection that can still hit busy during WAL checkpoint).

Includes a vitest concurrent-read-during-write smoke test.

Alfred and others added 2 commits May 25, 2026 01:21
WAL mode was already set; add busy_timeout=5000 and foreign_keys=ON to
complete the standard 3-pragma incantation for concurrent SQLite use.
Patches src/db.ts and both dist/ compiled outputs. Adds WAL smoke test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@obra
Copy link
Copy Markdown
Owner

obra commented May 28, 2026

Thanks for the contribution. Would you mind resubmitting this without a change to the version number inside the mcp?

The previous rebuild swept the bundled VERSION literal up to match
package.json (1.4.2). Reverting to 1.4.1 per maintainer request —
version bumps are owned by the maintainer, not this PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Dmheath1
Copy link
Copy Markdown
Author

Done. VERSION revert in a470b5f. PR diff is now just the two PRAGMA lines plus the smoke test.

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.

2 participants