bitbake: prserv: Ensure data is committed
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 8 Sep 2013 09:45:54 +0000 (09:45 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 8 Sep 2013 09:51:56 +0000 (10:51 +0100)
In exclusive mode, we need to complete the transaction for writes to make
it to the database. Therefore add sync calls to ensure this happens.

Autocommit mode is significantly (100 times) slower so caching the
data is of significant benefit.

(Bitbake rev: 4e55f7821786a59c2cd7dbd8bfa2a22f5f196e99)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/prserv/db.py
bitbake/lib/prserv/serv.py

index 5599355..86eafe3 100644 (file)
@@ -43,6 +43,10 @@ class PRTable(object):
                     continue
                 raise exc
 
+    def sync(self):
+        self.conn.commit()
+        self._execute("BEGIN EXCLUSIVE TRANSACTION")
+
     def _getValueHist(self, version, pkgarch, checksum):
         data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table,
                            (version, pkgarch, checksum))
index a9c7ed1..7864594 100644 (file)
@@ -74,7 +74,7 @@ class PRServer(SimpleXMLRPCServer):
             except:
                 self.handle_error(request, client_address)
                 self.shutdown_request(request)
-
+                self.table.sync()
 
     def process_request(self, request, client_address):
         self.requestqueue.put((request, client_address))
@@ -120,6 +120,7 @@ class PRServer(SimpleXMLRPCServer):
         while not self.quit:
             self.handle_request()
 
+        self.table.sync()
         logger.info("PRServer: stopping...")
         self.server_close()
         return