From 16cba6fdacd1f4e861d5477d2a3fb183415dd9e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 23:17:24 +0000 Subject: [PATCH 1/2] Initial plan From e5f21bea9174c64101396720c614b31be46ec8c1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 23:23:04 +0000 Subject: [PATCH 2/2] Add SQLite WAL mode and busy_timeout to prevent database locking errors Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- backend/db/index.ts | 6 ++++++ backend/db/minimal.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/backend/db/index.ts b/backend/db/index.ts index 458b13a..22089ff 100644 --- a/backend/db/index.ts +++ b/backend/db/index.ts @@ -50,6 +50,12 @@ async function openDatabase(options: DatabaseOpenOptions) { fileName = resolve(path, "main.db"); await Deno.mkdir(path, { recursive: true }); const database = new Database(fileName, options); + + // Enable WAL mode for better concurrency (allows concurrent readers and writers) + database.exec("PRAGMA journal_mode = WAL"); + // Set busy timeout to 30 seconds to wait for locks instead of failing immediately + database.exec("PRAGMA busy_timeout = 30000"); + return database; } diff --git a/backend/db/minimal.ts b/backend/db/minimal.ts index 545fb44..1ca0f83 100644 --- a/backend/db/minimal.ts +++ b/backend/db/minimal.ts @@ -6,6 +6,12 @@ async function openDatabase(options: DatabaseOpenOptions) { fileName = resolve(path, "main.db"); await Deno.mkdir(path, { recursive: true }); const database = new Database(fileName, options); + + // Enable WAL mode for better concurrency (allows concurrent readers and writers) + database.exec("PRAGMA journal_mode = WAL"); + // Set busy timeout to 30 seconds to wait for locks instead of failing immediately + database.exec("PRAGMA busy_timeout = 30000"); + return database; }