summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/prserv/serv.py
diff options
context:
space:
mode:
authorMichael Opdenacker <michael.opdenacker@bootlin.com>2024-05-11 16:31:31 +0530
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-05-21 14:23:43 +0100
commit65757c9e200cb34b39a87f3a8c2a8f8665a81677 (patch)
treefe5d13e4c96f99f6e176637f9d494c57553f597e /bitbake/lib/prserv/serv.py
parent4cbce9cdf7d22b0b4fe933867f931019540a6663 (diff)
downloadpoky-65757c9e200cb34b39a87f3a8c2a8f8665a81677.tar.gz
bitbake: prserv: enable database sharing
sqlite3 can allow multiple processes to access the database simultaneously, but it must be opened correctly. The key change is that the database is no longer opened in "exclusive" mode (defaulting to shared mode). In addition, the journal is set to "WAL" mode, as this is the most efficient for dealing with simultaneous access between different processes. In order to keep the database performance, synchronous mode is set to "off". The WAL journal will protect against incomplete transactions in any given client, however the database will not be protected against unexpected power loss from the OS (which is a fine trade off for performance, and also the same as the previous implementation). The use of a database cursor enabled to remove the _execute() wrapper. The cursor automatically makes sure that the query happens in an atomic transaction and commits when finished. This also removes the need for a "dirty" flag for the database and for explicit database syncing, which simplifies the code. (Bitbake rev: 385833243c495dc68ec26a963136c1ced3f272d0) Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Cc: Tim Orling <ticotimo@gmail.com> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv/serv.py')
-rw-r--r--bitbake/lib/prserv/serv.py9
1 files changed, 0 insertions, 9 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 05573d06cc..3992056f88 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -42,10 +42,7 @@ class PRServerClient(bb.asyncrpc.AsyncServerConnection):
42 try: 42 try:
43 return await super().dispatch_message(msg) 43 return await super().dispatch_message(msg)
44 except: 44 except:
45 self.server.table.sync()
46 raise 45 raise
47 else:
48 self.server.table.sync_if_dirty()
49 46
50 async def handle_test_pr(self, request): 47 async def handle_test_pr(self, request):
51 '''Finds the PR value corresponding to the request. If not found, returns None and doesn't insert a new value''' 48 '''Finds the PR value corresponding to the request. If not found, returns None and doesn't insert a new value'''
@@ -233,15 +230,9 @@ class PRServer(bb.asyncrpc.AsyncServer):
233 return tasks 230 return tasks
234 231
235 async def stop(self): 232 async def stop(self):
236 self.table.sync_if_dirty()
237 self.db.disconnect() 233 self.db.disconnect()
238 await super().stop() 234 await super().stop()
239 235
240 def signal_handler(self):
241 super().signal_handler()
242 if self.table:
243 self.table.sync()
244
245class PRServSingleton(object): 236class PRServSingleton(object):
246 def __init__(self, dbfile, logfile, host, port, upstream): 237 def __init__(self, dbfile, logfile, host, port, upstream):
247 self.dbfile = dbfile 238 self.dbfile = dbfile