From 9e36106642c27e4c9cde2f5b2f6e67b41bb6a8a0 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Wed, 8 Dec 2010 21:40:42 -0800 Subject: [PATCH] sqlite3: configure the timeout explicitly. In flush-cache.sh, we have to do this, because the sqlite3 command-line tool sets it to zero. Inevitably during parallel testing, it'll end up contending for a lock, and we really want it to wait a bit. In state.py, it's not as important since the default is nonzero. But python-sqlite3's default of 5 seconds makes me a little too nervous; I can imagine a disk write waiting for more than 5 seconds sometime. So let's use 60 instead. --- state.py | 5 +++-- t/flush-cache.sh | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/state.py b/state.py index 17a9e35..86a7b0d 100644 --- a/state.py +++ b/state.py @@ -3,6 +3,7 @@ import vars from helpers import unlink, err, debug2, debug3, mkdirp, close_on_exec SCHEMA_VER=7 +TIMEOUT=60 _db = None def db(): @@ -14,7 +15,7 @@ def db(): mkdirp(dbdir) must_create = not os.path.exists(dbfile) if not must_create: - _db = sqlite3.connect(dbfile) + _db = sqlite3.connect(dbfile, timeout=TIMEOUT) try: row = _db.cursor().execute("select version from Schema").fetchone() except sqlite3.OperationalError: @@ -27,7 +28,7 @@ def db(): _db = None if must_create: unlink(dbfile) - _db = sqlite3.connect(dbfile) + _db = sqlite3.connect(dbfile, timeout=TIMEOUT) _db.execute("create table Schema (version int)") _db.execute("create table Runid " " (id integer primary key autoincrement)") diff --git a/t/flush-cache.sh b/t/flush-cache.sh index 318838e..e464c96 100755 --- a/t/flush-cache.sh +++ b/t/flush-cache.sh @@ -1,6 +1,7 @@ #!/bin/sh #echo "Flushing redo cache..." >&2 ( + echo ".timeout 5000" echo "update Files set checked_runid=null;" echo "update Files set changed_runid=changed_runid-1;" #echo "update Files set stamp='dirty' where id in (select distinct target from Deps);"