Index: common.scm ================================================================== --- common.scm +++ common.scm @@ -1082,10 +1082,15 @@ (begin (sqlite3:interrupt! db) (sqlite3:finalize! db #t) ;; (vector-set! *task-db* 0 #f) (set! *task-db* #f))))) + (if (and *no-sync-db* + (sqlite3:database? *no-sync-db*)) + (begin + (sqlite3:interrupt! *no-sync-db*) + (sqlite3:finalize! *no-sync-db* #t))) (http-client#close-all-connections!) ;; (if (and *runremote* ;; (remote-conndat *runremote*)) ;; (begin ;; (http-client#close-all-connections!))) ;; for http-client Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -2167,14 +2167,20 @@ db)))) (mutex-unlock! *db-access-mutex*) res)) (define (db:no-sync-set db var val) - (sqlite3:execute (db:no-sync-db db) "INSERT OR REPLACE INTO no_sync_metadat (var,val) VALUES (?,?);" var val)) + ;; (mutex-lock! *db-access-mutex*) + (let ((res (sqlite3:execute (db:no-sync-db db) "INSERT OR REPLACE INTO no_sync_metadat (var,val) VALUES (?,?);" var val))) + ;; (mutex-unlock! *db-access-mutex*) + res)) (define (db:no-sync-del! db var) - (sqlite3:execute (db:no-sync-db db) "DELETE FROM no_sync_metadat WHERE var=?;" var)) + ;; (mutex-lock! *db-access-mutex*) + (sqlite3:execute (db:no-sync-db db) "DELETE FROM no_sync_metadat WHERE var=?;" var) + ;; (mutex-unlock! *db-access-mutex*) + ) (define (db:no-sync-get/default db var default) (let ((res default)) (sqlite3:for-each-row (lambda (val) @@ -3981,11 +3987,11 @@ ;; (("WARN" "DEAD") (define (db:set-state-status-and-roll-up-items dbstruct run-id test-name item-path state status comment) ;; establish info on incoming test followed by info on top level test ;; BBnote - for mode itemwait, linkage between upstream test & matching item status is propagated to run queue in db:prereqs-not-met - ;; (mutex-lock! *db-transaction-mutex*) ;; why do we need a mutex? + (mutex-lock! *db-transaction-mutex*) ;; why do we need a mutex? (let* ((testdat (if (number? test-name) (db:get-test-info-by-id dbstruct run-id test-name) ;; test-name is actually a test-id (db:get-test-info dbstruct run-id test-name item-path))) (test-id (db:test-get-id testdat)) (test-name (if (number? test-name) @@ -3999,11 +4005,10 @@ (db:test-set-state-status dbstruct run-id test-id state status #f) (if (and test-id state status (equal? status "AUTO")) (db:test-data-rollup dbstruct run-id test-id status)) (if (member state '("LAUNCHED" "REMOTEHOSTSTART")) (db:general-call dbstruct 'set-test-start-time (list test-id))) - (if (not (equal? item-path "")) ;; only roll up IF incoming test is an item (begin ;; is there a rollup lock? If not, take it (sqlite3:with-transaction no-sync-db @@ -4030,18 +4035,21 @@ no-sync-db (lambda () (db:no-sync-set no-sync-db rollup-lock-key (current-seconds)) (db:no-sync-del! no-sync-db waiting-lock-key)))))) ;; now the rollup + (mutex-unlock! *db-transaction-mutex*) ;; why do we need a mutex? (if rollup-flag ;; put this into a thread (begin ;; (thread-start! (make-thread ;; (lambda () (db:roll-up-test-state-status dbstruct run-id test-name state status) (db:no-sync-del! no-sync-db rollup-lock-key)) ;; (conc "thread for run-id: " run-id " test-name: " test-name)))))))) - ))))) + )) + (mutex-unlock! *db-transaction-mutex*) ;; why do we need a mutex? + ))) ;; I'd like to remove the need for item-path - it is logically not needed here ;; for now we pass in state and status - NOTE: There is a possible race if a test ;; is rapidly re-run while an earlier run is waiting to rollup. ;;