[LNT] r307807 - v4db: Increase sqlite timeout waiting for a locked database

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 09:14:58 PDT 2017


Author: matze
Date: Wed Jul 12 09:14:58 2017
New Revision: 307807

URL: http://llvm.org/viewvc/llvm-project?rev=307807&view=rev
Log:
v4db: Increase sqlite timeout waiting for a locked database

This reduces the chance for problems when blasting an sqlite testserver
with submissions.
It does not affect postgres users.

Modified:
    lnt/trunk/lnt/server/db/v4db.py

Modified: lnt/trunk/lnt/server/db/v4db.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/v4db.py?rev=307807&r1=307806&r2=307807&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/v4db.py (original)
+++ lnt/trunk/lnt/server/db/v4db.py Wed Jul 12 09:14:58 2017
@@ -114,7 +114,15 @@ class V4DB(object):
         self.echo = echo
         with V4DB._engine_lock:
             if path not in V4DB._engine:
-                V4DB._engine[path] = sqlalchemy.create_engine(path, echo=echo)
+                connect_args = {}
+                if path.startswith("sqlite://"):
+                    # Some of the background tasks keep database transactions
+                    # open for a long time. Make it less likely to hit
+                    # "(OperationalError) database is locked" because of that.
+                    connect_args['timeout'] = 30
+                engine = sqlalchemy.create_engine(path, echo=echo,
+                                                  connect_args=connect_args)
+                V4DB._engine[path] = engine
         self.engine = V4DB._engine[path]
 
         # Update the database to the current version, if necessary. Only check




More information about the llvm-commits mailing list