Skip to content

Commit

Permalink
print sqlite version when pool is loaded
Browse files Browse the repository at this point in the history
This also checks for and logs about concurrency problems in older
versions of SQLite.  Refs #2005.
  • Loading branch information
djmitche committed Jul 3, 2011
1 parent 344e2bd commit 6bd279c
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions master/buildbot/db/pool.py
Expand Up @@ -82,8 +82,15 @@ def __init__(self, engine):
name='DBThreadPool')
self.engine = engine
if engine.dialect.name == 'sqlite':
log.msg("applying SQLite workaround from Buildbot bug #1810")
self.__broken_sqlite = self.detect_bug1810()
vers = self.get_sqlite_version()
log.msg("Using SQLite Version %s" % (vers,))
if vers < (3,3,17):
log.msg("NOTE: this old version of SQLite does not support "
"multiple simultaneous accesses to the database; "
"add the 'pool_size=1' argument to your db url")
brkn = self.__broken_sqlite = self.detect_bug1810()
if brkn:
log.msg("Applying SQLite workaround from Buildbot bug #1810")
self._start_evt = reactor.callWhenRunning(self._start)

# patch the do methods to do verbose logging if necessary
Expand Down Expand Up @@ -237,3 +244,22 @@ def test(select_from_sqlite_master=False):
test(select_from_sqlite_master=True)
shutil.rmtree(tmpdir)
return False # not broken - no workaround required

def get_sqlite_version(self):
engine = sa.create_engine('sqlite://')
conn = engine.contextual_connect()

try:
r = conn.execute("SELECT sqlite_version()")
vers_row = r.fetchone()
r.close()
except:
return (0,)

if vers_row:
try:
return tuple(map(int, vers_row[0].split('.')))
except (TypeError, ValueError):
return (0,)
else:
return (0,)

0 comments on commit 6bd279c

Please sign in to comment.