From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: bitbake-devel <bitbake-devel@lists.openembedded.org>
Subject: [PATCH] serv/db: Don't use BEGIN/COMMIT
Date: Sat, 31 Aug 2013 23:42:13 +0100 [thread overview]
Message-ID: <1377988933.1059.131.camel@ted> (raw)
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>
---
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py
index b7190ba..dad445b 100644
--- a/bitbake/lib/prserv/db.py
+++ b/bitbake/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))
reply other threads:[~2013-08-31 22:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377988933.1059.131.camel@ted \
--to=richard.purdie@linuxfoundation.org \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.