Skip to content

Commit ec96a52

Browse files
committed
Add busy_timeout to the local libSQL connection
Match the self-host open path: a per-connection PRAGMA busy_timeout=5000 gives writers a 5s retry window instead of an instant SQLITE_BUSY when a second OS process transiently holds the write lock (a CLI tool, the v1->v2 migration reader, or a launchd restart racing the old pid).
1 parent ce39ffc commit ec96a52

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

apps/local/src/db/libsql.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ export const openLocalLibsql = async (path: string): Promise<Client> => {
2626
// first enabling. Re-apply both since libSQL gives no shared handle.
2727
await client.execute("PRAGMA foreign_keys = ON");
2828
await client.execute("PRAGMA journal_mode = WAL");
29+
// busy_timeout is per-connection (default 0 = fail immediately on a lock).
30+
// Under the supervised-daemon model a single process owns this file, but a
31+
// second OS process can still transiently hold the write lock (e.g. a CLI
32+
// tool, the v1→v2 migration reader, or a launchd restart racing the old
33+
// pid). Give writers a 5s retry window instead of an instant SQLITE_BUSY.
34+
// Matches the self-host open path (self-host-db.ts).
35+
await client.execute("PRAGMA busy_timeout = 5000");
2936
return client;
3037
};
3138

0 commit comments

Comments
 (0)