fix(database): enable WAL mode and busy_timeout on every DB connection
Applies WAL journal, 5s busy_timeout, synchronous=NORMAL, and foreign_keys=ON pragmas immediately after opening each connection so concurrent main+worker writers share the same locking configuration and avoid SQLITE_BUSY under contention.
This commit is contained in:
1 parent
a6d0a567a8
commit
5201b6623b
1 file changed
+6
-1
@@ -378,7 +378,12 @@ export class AppDatabaseBase {
|
||||
}
|
||||
|
||||
protected openConnection(): DatabaseSync {
|
||||
return new DatabaseSync(this.dbPath, { timeout: 5000 });
|
||||
const db = new DatabaseSync(this.dbPath, { timeout: 5000 });
|
||||
db.exec("pragma journal_mode = WAL;");
|
||||
db.exec("pragma busy_timeout = 5000;");
|
||||
db.exec("pragma synchronous = NORMAL;");
|
||||
db.exec("pragma foreign_keys = ON;");
|
||||
return db;
|
||||
}
|
||||
|
||||
protected transaction<T>(operation: () => T): T {
|
||||
|
||||
Reference in new issue
Block a user