Repository navigation
Description
Observed on squirrel v0.0.138; the relevant code is unchanged on current main.
Problem
Running several squirrel audit processes at once (4 to 10 audits of different sites on one machine) makes a fraction of them fail and write no report:
Audit failed: Storage error during read: SQLite database is busy (locked). Another squirrelscan crawl/report/analyze command may be running in parallel. Wait for it to finish and retry.
The audited sites are different, so the only thing the processes share is the machine-wide store ~/.squirrel/content-store.db (and the link cache next to it). Auditing different sites in parallel is a normal batch pattern and should not fail.
Repro: for i in 1 2 3 4 5 6 7 8 9 10; do squirrel audit https://site$i.example.com --max-pages 30 -f json -o out$i.json & done; wait, then count the processes that exit non-zero with the message above.
Where to look
The stores already set PRAGMA busy_timeout = 15000, but in apps/cli/src/crawler/storage/content-store.ts (getDb) and packages/crawler/src/storage/sqlite.ts (init) the timeout is set after PRAGMA journal_mode = WAL, wal_autocheckpoint and synchronous, and before the schema runs. SQLite's default busy timeout is 0, so the very first statements on a fresh connection (the WAL switch and the first schema statements, which need a lock) fail immediately with SQLITE_BUSY when another process holds the write lock. Candidates to check:
- Set
busy_timeoutfirst, beforejournal_mode = WAL. - Write transactions begun as deferred
BEGINthat later upgrade to a write lock fail at once under WAL (SQLITE_BUSY_SNAPSHOT is not retried by the busy handler); useBEGIN IMMEDIATEfor write transactions. - A single large write transaction (for example a big eviction pass or a bulk page insert) holding the lock longer than 15 seconds under 10-way contention.
Acceptance Criteria
- 10 concurrent
squirrel auditruns of 10 different sites on one machine all complete and write their reports, repeated 5 times with noSQLite database is busyfailure. -
busy_timeoutis the first pragma applied on every connection tocontent-store.db, the link cache andproject.db. - Write transactions that can contend use
BEGIN IMMEDIATE(or an equivalent retry), covered by a test with two processes writing at once. - If the lock still cannot be acquired within the timeout, the error says which database file was busy and how long it waited.
Activity
fix(core-contracts): read the busy-file suffix without a regex (CodeQ…
docs(cli): parallel audits need a local disk; the wait is per statement
fix(crawler,cli): parallel audits no longer fail with SQLite busy: bu…
fix(core-contracts): read the busy-file suffix without a regex (CodeQ…
docs(cli): parallel audits need a local disk; the wait is per statement
nc9 commentedon Oct 30, 2026
Shipped in v0.0.143 (commits 546e098, 14fee0e, b8018fb). Checked every acceptance criterion against current main: parallel audits no longer fail with SQLite busy. I also ran the literal repro on main: 10 concurrent
squirrel auditruns of 10 different sites, repeated 5 times, 50 of 50 exited 0 with a report and no busy error.nik