Index: dbmod.scm ================================================================== --- dbmod.scm +++ dbmod.scm @@ -208,23 +208,26 @@ (dbr:dbstruct-dbfname-set! dbstruct dbfname) (dbr:dbstruct-sync-proc-set! dbstruct (lambda (last-update) (if *sync-in-progress* (debug:print 3 *default-log-port* "WARNING: overlapping calls to sync to disk") - (let* ((sync-cmd (conc "megatest -db2db -from "tmpdb" -to "dbfullname"&"))) + (let* ((sync-cmd (conc "megatest -db2db -from "tmpdb" -to "dbfullname"&")) + (synclock-file (conc dbfullname".sync-lock"))) ;; (mutex-lock! *db-with-db-mutex*) ;; this mutex is used when overloaded or during a query that modifies the db - (set! *sync-in-progress* #t) ;; (if (eq? (dbfile:cache-method) 'inmem) ;; (dbmod:sync-gasket tables last-update inmem db ;; dbfullname syncdir keys) - (thread-start! (make-thread - (lambda () - (debug:print-info "Running "sync-cmd) - (system sync-cmd) - ;; (mutex-unlock! *db-with-db-mutex*) - ;; (thread-sleep! 0.5) ;; ensure at least 1/2 second down time between sync calls - (set! *sync-in-progress* #f)))) + (if (file-exists? synclock-file) + (debug:print 0 *default-log-port* "Skipping sync, lockfile "synclock-file" found.") + (thread-start! (make-thread + (lambda () + (set! *sync-in-progress* #t) + (debug:print-info "Running "sync-cmd) + (system sync-cmd) + ;; (mutex-unlock! *db-with-db-mutex*) + ;; (thread-sleep! 0.5) ;; ensure at least 1/2 second down time between sync calls + (set! *sync-in-progress* #f))))) )))) ;; (dbmod:sync-tables tables #f db inmem) ;; (if db (dbmod:sync-gasket tables #f inmem db dbfullname 'fromdest keys) ;; ) ;; load into inmem (dbr:dbstruct-last-update-set! dbstruct (current-seconds)) ;; should this be offset back in time by one second?