summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
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 15:51:11 +0100
commitbd023ef9c093b7e79bf44d8332744161eed56a18 (patch)
tree79496bfe7210ebebda3f2bf828433d73134f3815 /bitbake/lib
parent883813deae842c25d9172aeceb5302fdec1258df (diff)
downloadpoky-bd023ef9c093b7e79bf44d8332744161eed56a18.tar.gz
bitbake: 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. (Bitbake rev: 42144a54979658f93fbbb43f7e271c1fff4d88ff) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/prserv/db.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py
index 3fb2c3482a..559935544a 100644
--- a/bitbake/lib/prserv/db.py
+++ b/bitbake/lib/prserv/db.py
@@ -52,11 +52,9 @@ class PRTable(object):
52 else: 52 else:
53 #no value found, try to insert 53 #no value found, try to insert
54 try: 54 try:
55 self._execute("BEGIN") 55 self._execute("INSERT INTO %s VALUES (?, ?, ?, (select ifnull(max(value)+1,0) from %s where version=? AND pkgarch=?));"
56 self._execute("INSERT OR ROLLBACK INTO %s VALUES (?, ?, ?, (select ifnull(max(value)+1,0) from %s where version=? AND pkgarch=?));"
57 % (self.table,self.table), 56 % (self.table,self.table),
58 (version,pkgarch, checksum,version, pkgarch)) 57 (version,pkgarch, checksum,version, pkgarch))
59 self.conn.commit()
60 except sqlite3.IntegrityError as exc: 58 except sqlite3.IntegrityError as exc:
61 logger.error(str(exc)) 59 logger.error(str(exc))
62 60
@@ -80,11 +78,9 @@ class PRTable(object):
80 else: 78 else:
81 #no value found, try to insert 79 #no value found, try to insert
82 try: 80 try:
83 self._execute("BEGIN")
84 self._execute("INSERT OR REPLACE INTO %s VALUES (?, ?, ?, (select ifnull(max(value)+1,0) from %s where version=? AND pkgarch=?));" 81 self._execute("INSERT OR REPLACE INTO %s VALUES (?, ?, ?, (select ifnull(max(value)+1,0) from %s where version=? AND pkgarch=?));"
85 % (self.table,self.table), 82 % (self.table,self.table),
86 (version, pkgarch, checksum, version, pkgarch)) 83 (version, pkgarch, checksum, version, pkgarch))
87 self.conn.commit()
88 except sqlite3.IntegrityError as exc: 84 except sqlite3.IntegrityError as exc:
89 logger.error(str(exc)) 85 logger.error(str(exc))
90 self.conn.rollback() 86 self.conn.rollback()
@@ -113,10 +109,8 @@ class PRTable(object):
113 else: 109 else:
114 #no value found, try to insert 110 #no value found, try to insert
115 try: 111 try:
116 self._execute("BEGIN") 112 self._execute("INSERT INTO %s VALUES (?, ?, ?, ?);" % (self.table),
117 self._execute("INSERT OR ROLLBACK INTO %s VALUES (?, ?, ?, ?);" % (self.table),
118 (version, pkgarch, checksum, value)) 113 (version, pkgarch, checksum, value))
119 self.conn.commit()
120 except sqlite3.IntegrityError as exc: 114 except sqlite3.IntegrityError as exc:
121 logger.error(str(exc)) 115 logger.error(str(exc))
122 116
@@ -130,18 +124,14 @@ class PRTable(object):
130 def _importNohist(self, version, pkgarch, checksum, value): 124 def _importNohist(self, version, pkgarch, checksum, value):
131 try: 125 try:
132 #try to insert 126 #try to insert
133 self._execute("BEGIN") 127 self._execute("INSERT INTO %s VALUES (?, ?, ?, ?);" % (self.table),
134 self._execute("INSERT OR ROLLBACK INTO %s VALUES (?, ?, ?, ?);" % (self.table),
135 (version, pkgarch, checksum,value)) 128 (version, pkgarch, checksum,value))
136 self.conn.commit()
137 except sqlite3.IntegrityError as exc: 129 except sqlite3.IntegrityError as exc:
138 #already have the record, try to update 130 #already have the record, try to update
139 try: 131 try:
140 self._execute("BEGIN")
141 self._execute("UPDATE %s SET value=? WHERE version=? AND pkgarch=? AND checksum=? AND value<?" 132 self._execute("UPDATE %s SET value=? WHERE version=? AND pkgarch=? AND checksum=? AND value<?"
142 % (self.table), 133 % (self.table),
143 (value,version,pkgarch,checksum,value)) 134 (value,version,pkgarch,checksum,value))
144 self.conn.commit()
145 except sqlite3.IntegrityError as exc: 135 except sqlite3.IntegrityError as exc:
146 logger.error(str(exc)) 136 logger.error(str(exc))
147 137