Add busy_timeout pragma to avoid SQLITE_BUSY during docker build

Next's build-time page-data collection evaluates route modules across
multiple worker processes concurrently. On a fresh (empty) data volume
— as in a clean docker build — two workers racing to create/open
db.sqlite for the first time hit SQLITE_BUSY instead of just waiting the
few ms for the other's lock. Reproduced by this session's docker build
after adding the attachments route; local builds never hit it since the
dev data/ directory already existed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QcXH24ky6zjk2UyK5oZUPH
This commit is contained in:
ogrechkoandClaude Sonnet 5 committed 2026-07-26 17:34:48 +00:00
1 parent 89b9c5eaac
commit 8121d8aa51
1 file changed
+5
+5
View File
@@ -10,6 +10,11 @@ fs.mkdirSync(dataDir, { recursive: true });
const sqlite = new Database(path.join(dataDir, "db.sqlite"));
sqlite.pragma("journal_mode = WAL");
sqlite.pragma("foreign_keys = ON");
// Next's build-time page-data collection evaluates route modules across
// several worker processes concurrently — without this, two workers
// racing to open/initialize a fresh db.sqlite can throw SQLITE_BUSY
// instead of just waiting the few ms for the other's lock to clear.
sqlite.pragma("busy_timeout = 5000");
export const db = drizzle(sqlite, { schema });
export type DB = typeof db;