Index: dbfile.scm ================================================================== --- dbfile.scm +++ dbfile.scm @@ -1010,10 +1010,11 @@ (jfile (conc fname"-journal")) #;(subdb (if have-struct (dbfile:get-subdb dbstruct run-id) #f)) ) ;; was 25 + (assert (sqlite3:database? db) "FATAL: db:with-db, db is not a database, db="db", fname="fname) (if (file-exists? jfile) (begin (dbfile:print-err "INFO: "jfile" exists, delaying to reduce database load") (thread-sleep! 0.2))) (if (and use-mutex Index: http-transport.scm ================================================================== --- http-transport.scm +++ http-transport.scm @@ -504,11 +504,23 @@ (if (and no-sync-db (common:low-noise-print 10 "sync-all")) ;; cheesy way to reduce frequency of running sync :) (begin (if (common:low-noise-print 120 "sync-all-print") (debug:print 0 *default-log-port* "keep-running calling db:all-db-sync at " (time->string (seconds->local-time) "%H:%M:%S"))) - (db:all-db-sync *dbstruct-dbs*)))) + (db:all-db-sync *dbstruct-dbs*) + (if (common:low-noise-print 1800 "sync-back") ;; every half hour do a reverse sync + (let* ((lockfile (conc *toppath*"/.megatest/syncback.lock")) + (locked (common:simple-file-lock lockfile))) + (if locked + (begin + (db:multi-db-sync + *dbstruct-dbs* + 'dejunk + 'adj-testids + 'old2new) + (common:simple-file-release-lock lockfile))))) + ))) ;; when things go wrong we don't want to be doing the various queries too often ;; so we strive to run this stuff only every four seconds or so. (let* ((sync-time (- (current-milliseconds) start-time)) (rem-time (quotient (- 4000 sync-time) 1000)))