From f016caa51300f7b127950b5c8e81463d3fbdeafc Mon Sep 17 00:00:00 2001 From: Joseph Benguira Date: Sun, 31 Jul 2022 18:51:53 +0300 Subject: [PATCH] Avoid error "SQLITE_BUSY: database is locked" Avoid error "SQLITE_BUSY: database is locked" by allowing SQLITE to wait up to 5 seconds to do a write --- server/database.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/database.js b/server/database.js index 00fd48d9..b58daf87 100644 --- a/server/database.js +++ b/server/database.js @@ -146,6 +146,9 @@ class Database { } await R.exec("PRAGMA cache_size = -12000"); await R.exec("PRAGMA auto_vacuum = FULL"); + + //Avoid error "SQLITE_BUSY: database is locked" by allowing SQLITE to wait up to 5 seconds to do a write + await R.exec("PRAGMA busy_timeout = 5000;"); // This ensures that an operating system crash or power failure will not corrupt the database. // FULL synchronous is very safe, but it is also slower.