Index: lock-queue.scm
==================================================================
--- lock-queue.scm
+++ lock-queue.scm
@@ -193,11 +193,14 @@
        (thread-sleep! 10)
        (if (> count 0)
 	   (begin
 	     (sqlite3:finalize! db)
 	     (lock-queue:wait-turn fname test-id count: (- count 1)))
-	   #f))
+	   (begin
+	     (debug:print 0 "Giving up calls to lock-queue:wait-turn for test-id " test-id " at path " fname ", printing call chain")
+	     (print-call-chain)
+	     #f)))
      (tasks:wait-on-journal (lock-queue:db-dat-get-path dbdat) 1200 waiting-msg: "lock-queue:wait-turn; waiting on journal file")
      (sqlite3:execute
       db
       "INSERT OR REPLACE INTO queue (test_id,start_time,state) VALUES (?,?,'waiting');"
       test-id mystart)

Index: tasks.scm
==================================================================
--- tasks.scm
+++ tasks.scm
@@ -290,23 +290,36 @@
      mdb
      (conc "SELECT " selstr " FROM servers WHERE run_id=? AND state in ('available','running','dbprep') ORDER BY start_time DESC;")
      run-id)
     (vector header res)))
 
-(define (tasks:get-server mdb run-id)
+(define (tasks:get-server mdb run-id #!key (retries 10))
   (let ((res  #f)
 	(best #f))
-    (sqlite3:for-each-row
-     (lambda (id interface port pubport transport pid hostname)
-       (set! res (vector id interface port pubport transport pid hostname)))
-     mdb
-     ;; removed:
-     ;; strftime('%s','now')-heartbeat < 10 AND mt_version = ?
-     "SELECT id,interface,port,pubport,transport,pid,hostname FROM servers
+    (handle-exceptions
+     exn
+     (begin 
+       (debug:print 0 "WARNING: tasks:get-server db access error.")
+	   (debug:print 0 " message: " ((condition-property-accessor 'exn 'message) exn))
+	   (debug:print 0 " for run " run-id)
+	   (print-call-chain)
+	   (if (> retries 0)
+	       (begin
+		 (debug:print 0 " trying call to tasks:get-server again in 10 seconds")
+		 (thread-sleep! 10)
+		 (tasks:get-server mdb run-id retries: (- retries 0)))
+	       (debug:print 0 "10 tries of tasks:get-server all crashed and burned. Giving up and returning \"no server found\"")))
+     (sqlite3:for-each-row
+      (lambda (id interface port pubport transport pid hostname)
+	(set! res (vector id interface port pubport transport pid hostname)))
+      mdb
+      ;; removed:
+      ;; strftime('%s','now')-heartbeat < 10 AND mt_version = ?
+      "SELECT id,interface,port,pubport,transport,pid,hostname FROM servers
           WHERE run_id=? AND state='running'
           ORDER BY start_time DESC LIMIT 1;" run-id) ;; (common:version-signature) run-id)
-    res))
+     res)))
 
 (define (tasks:server-running-or-starting? mdb run-id)
   (let ((res #f))
     (sqlite3:for-each-row
      (lambda (id)

Index: tdb.scm
==================================================================
--- tdb.scm
+++ tdb.scm
@@ -110,21 +110,24 @@
 	 (tdb        (open-test-db test-path)))
     (apply proc tdb params)))
 
 (define (tdb:testdb-initialize db)
   (debug:print 11 "db:testdb-initialize START")
-  (for-each
-   (lambda (sqlcmd)
-     (sqlite3:execute db sqlcmd))
-   (list "CREATE TABLE IF NOT EXISTS test_rundat (
+  (sqlite3:with-transaction
+   db
+   (lambda ()
+     (for-each
+      (lambda (sqlcmd)
+	(sqlite3:execute db sqlcmd))
+      (list "CREATE TABLE IF NOT EXISTS test_rundat (
               id INTEGER PRIMARY KEY,
               update_time TIMESTAMP,
               cpuload INTEGER DEFAULT -1,
               diskfree INTEGER DEFAULT -1,
               diskusage INTGER DEFAULT -1,
               run_duration INTEGER DEFAULT 0);"
-	 "CREATE TABLE IF NOT EXISTS test_data (
+	    "CREATE TABLE IF NOT EXISTS test_data (
               id INTEGER PRIMARY KEY,
               test_id INTEGER,
               category TEXT DEFAULT '',
               variable TEXT,
 	      value REAL,
@@ -133,29 +136,29 @@
               units TEXT,
               comment TEXT DEFAULT '',
               status TEXT DEFAULT 'n/a',
               type TEXT DEFAULT '',
               CONSTRAINT test_data_constraint UNIQUE (test_id,category,variable));"
-	 "CREATE TABLE IF NOT EXISTS test_steps (
+	    "CREATE TABLE IF NOT EXISTS test_steps (
               id INTEGER PRIMARY KEY,
               test_id INTEGER, 
               stepname TEXT, 
               state TEXT DEFAULT 'NOT_STARTED', 
               status TEXT DEFAULT 'n/a',
               event_time TIMESTAMP,
               comment TEXT DEFAULT '',
               logfile TEXT DEFAULT '',
               CONSTRAINT test_steps_constraint UNIQUE (test_id,stepname,state));"
-	 ;; test_meta can be used for handing commands to the test
-	 ;; e.g. KILLREQ
-	 ;;      the ackstate is set to 1 once the command has been completed
-	 "CREATE TABLE IF NOT EXISTS test_meta (
+	    ;; test_meta can be used for handing commands to the test
+	    ;; e.g. KILLREQ
+	    ;;      the ackstate is set to 1 once the command has been completed
+	    "CREATE TABLE IF NOT EXISTS test_meta (
               id INTEGER PRIMARY KEY,
               var TEXT,
               val TEXT,
               ackstate INTEGER DEFAULT 0,
-              CONSTRAINT metadat_constraint UNIQUE (var));"))
+              CONSTRAINT metadat_constraint UNIQUE (var));"))))
   (debug:print 11 "db:testdb-initialize END"))
 
 (define (tdb:read-test-data tdb test-id categorypatt)
   (let ((res '()))
     (sqlite3:for-each-row