summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-31 23:42:13 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-09-01 08:54:21 +0100
commit42144a54979658f93fbbb43f7e271c1fff4d88ff (patch)
tree943be4f987080a58026d479f75990115580eba43
parente3e39be6f2d063858c92971ce8ccd89c95d4f26d (diff)
downloadbitbake-42144a54979658f93fbbb43f7e271c1fff4d88ff.tar.gz
serv/db: Don't use BEGIN/COMMIT
Since we don't support using multiple servers on the same database file, don't use the BEGIN/COMMIT syntax and allow writes to the database to work ~100 times faster with no transaction locking. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/prserv/db.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/prserv/db.py b/lib/prserv/db.py
index 3fb2c3482..559935544 100644
--- a/lib/prserv/db.py
+++ b/lib/prserv/db.py
@@ -52,11 +52,9 @@ class PRTable(object):
else:
#no value found, try to insert
try:
- self._execute("BEGIN")
- self._execute("INSERT OR ROLLBACK INTO %s VALUES (?, ?, ?, (select ifnull(max(value)+1,0) from %s where version=? AND pkgarch=?));"
+ self._execute("INSERT INTO %s VALUES (?, ?, ?, (select ifnull(max(value)+1,0) from %s where version=? AND pkgarch=?));"
% (self.table,self.table),
(version,pkgarch, checksum,version, pkgarch))
- self.conn.commit()
except sqlite3.IntegrityError as exc:
logger.error(str(exc))
@@ -80,11 +78,9 @@ class PRTable(object):
else:
#no value found, try to insert
try:
- self._execute("BEGIN")
self._execute("INSERT OR REPLACE INTO %s VALUES (?, ?, ?, (select ifnull(max(value)+1,0) from %s where version=? AND pkgarch=?));"
% (self.table,self.table),
(version, pkgarch, checksum, version, pkgarch))
- self.conn.commit()
except sqlite3.IntegrityError as exc:
logger.error(str(exc))
self.conn.rollback()
@@ -113,10 +109,8 @@ class PRTable(object):
else:
#no value found, try to insert
try:
- self._execute("BEGIN")
- self._execute("INSERT OR ROLLBACK INTO %s VALUES (?, ?, ?, ?);" % (self.table),
+ self._execute("INSERT INTO %s VALUES (?, ?, ?, ?);" % (self.table),
(version, pkgarch, checksum, value))
- self.conn.commit()
except sqlite3.IntegrityError as exc:
logger.error(str(exc))
@@ -130,18 +124,14 @@ class PRTable(object):
def _importNohist(self, version, pkgarch, checksum, value):
try:
#try to insert
- self._execute("BEGIN")
- self._execute("INSERT OR ROLLBACK INTO %s VALUES (?, ?, ?, ?);" % (self.table),
+ self._execute("INSERT INTO %s VALUES (?, ?, ?, ?);" % (self.table),
(version, pkgarch, checksum,value))
- self.conn.commit()
except sqlite3.IntegrityError as exc:
#already have the record, try to update
try:
- self._execute("BEGIN")
self._execute("UPDATE %s SET value=? WHERE version=? AND pkgarch=? AND checksum=? AND value<?"
% (self.table),
(value,version,pkgarch,checksum,value))
- self.conn.commit()
except sqlite3.IntegrityError as exc:
logger.error(str(exc))