aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hashserv
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2023-12-04 09:03:43 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-04 22:35:59 +0000
commitc5b8c91d325ed1ca8abe5fe28d989693555c0622 (patch)
treefe43c2203cde18ccde394669aa5a51a5d916af7e /lib/hashserv
parent1ab1d36c0af6fc58a974106b61ff4d37da6cb229 (diff)
downloadbitbake-c5b8c91d325ed1ca8abe5fe28d989693555c0622.tar.gz
hashserv: sqlite: Ensure sync propagates to database connections
When the sqlite database backend was restructured, the code to make the databases run in WAL mode and to control if sync() is called was accidentally dropped. This caused terrible database performance to the point that server timeouts were occurring causing really slow builds. Fix this by properly enabling WAL mode and setting the synchronous flag as requested Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/hashserv')
-rw-r--r--lib/hashserv/sqlite.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/hashserv/sqlite.py b/lib/hashserv/sqlite.py
index f65036be9..f93cb2c1d 100644
--- a/lib/hashserv/sqlite.py
+++ b/lib/hashserv/sqlite.py
@@ -109,11 +109,11 @@ class DatabaseEngine(object):
)
def connect(self, logger):
- return Database(logger, self.dbname)
+ return Database(logger, self.dbname, self.sync)
class Database(object):
- def __init__(self, logger, dbname, sync=True):
+ def __init__(self, logger, dbname, sync):
self.dbname = dbname
self.logger = logger
@@ -121,6 +121,11 @@ class Database(object):
self.db.row_factory = sqlite3.Row
with closing(self.db.cursor()) as cursor:
+ cursor.execute("PRAGMA journal_mode = WAL")
+ cursor.execute(
+ "PRAGMA synchronous = %s" % ("NORMAL" if sync else "OFF")
+ )
+
cursor.execute("SELECT sqlite_version()")
version = []