Keep the app's own writes from being refused as locked while one of its transactions is open

SQLite lets one writer in at a time and refuses a second at once. A write that landed in the pauses of an in-process transaction (the diagnostic log trimming itself, an agent report) was refused with SQLITE_BUSY, and the refused statement left the next transaction unable to commit. Ordinary writes and the next transaction now wait for the open transaction; reads are never held, and a wait over 10 s is given up.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-04 22:12:56 +01:00
1 parent c79b2eda0d
commit c7775e5dd9
4 files changed
+269

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ what the app actually creates.
|---|---|
| **File** | `DATABASE_PATH`, default `../data/homelab-manager.sqlite` (relative to `server/`; `/app/data/...` in Docker). The folder is created if missing. |
| **Foreign keys** | Switched on for every connection (`PRAGMA foreign_keys = ON`), so the `ON DELETE` rules below are enforced. |
| **Writes** | SQLite lets one writer in at a time and refuses a second at once ("database is locked"). While a transaction of the app is open, its other writes wait for it ([`server/src/db/writeGate.ts`](server/src/db/writeGate.ts)) rather than being refused — a refused write also leaves its connection unable to commit the next transaction. Reads are never held; a wait over 10 seconds is given up. A lock held by *another* process (a backup tool reading the file, a second copy of the app) is still refused as before. |
| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0082`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. |
| **Tables** | 91 application tables, plus drizzle's own `__drizzle_migrations`. |