fix(TRUEREF-0021): reduce event loop blocking, add busy_timeout, and add TRUEREF-0022 PRD

This commit is contained in:
U811073
2026-03-30 15:06:54 +02:00
committed by Giancarmine Salucci
parent f4fe8c6043
commit 6f3f4db19b
6 changed files with 577 additions and 34 deletions

View File

@@ -13,6 +13,7 @@ export function getClient(): Database.Database {
_client = new Database(env.DATABASE_URL);
_client.pragma('journal_mode = WAL');
_client.pragma('foreign_keys = ON');
_client.pragma('busy_timeout = 5000');
}
return _client;
}

View File

@@ -15,6 +15,10 @@ const client = new Database(env.DATABASE_URL);
client.pragma('journal_mode = WAL');
// Enforce foreign key constraints.
client.pragma('foreign_keys = ON');
// Wait up to 5 s when the DB is locked instead of failing immediately.
// Prevents SQLITE_BUSY errors when the indexing pipeline holds the write lock
// and an HTTP request arrives simultaneously.
client.pragma('busy_timeout = 5000');
export const db = drizzle(client, { schema });