@@ -551,18 +551,15 @@ ((and changed *time-to-exit*) ;; last sync #t) (else #f)))) (if (or dejunk do-cp) - (let* ( - (start-time (current-milliseconds)) + (let* ((start-time (current-milliseconds)) (subdb (or (dbfile:get-subdb dbstruct run-id) (dbfile:init-subdb dbstruct run-id dbfile:db-init-proc))) (mtdb (dbr:subdb-mtdbdat subdb)) - (tmpdb (dbfile:open-db dbstruct run-id dbfile:db-init-proc)) - - ) + (tmpdb (dbfile:open-db dbstruct run-id dbfile:db-init-proc))) (debug:print-info 2 *default-log-port* "delta syncing file: " srcfile ", time diff: " (- time1 time2) " seconds") (if old2new (begin (if dejunk (db:clean-up run-id mtdb)) @@ -4349,38 +4346,38 @@ ;;====================================================================== ;; currently the primary job of the watchdog is to run the sync back to megatest.db from the db in /tmp ;; if we are on the homehost and we are a server (by definition we are on the homehost if we are a server) ;; -(define (common:readonly-watchdog dbstruct) - (thread-sleep! 0.05) ;; delay for startup - (debug:print-info 13 *default-log-port* "common:readonly-watchdog entered.") - ;; sync megatest.db to /tmp/.../megatst.db - (let* ((sync-cool-off-duration 3) - (golden-mtdb (dbr:dbstruct-mtdb dbstruct)) - (golden-mtpath (db:dbdat-get-path golden-mtdb)) - (tmp-mtdb (dbr:dbstruct-tmpdb dbstruct)) - (tmp-mtpath (db:dbdat-get-path tmp-mtdb))) - (debug:print-info 0 *default-log-port* "Read-only periodic sync thread started.") - (let loop ((last-sync-time 0)) - (debug:print-info 13 *default-log-port* "loop top tmp-mtpath="tmp-mtpath" golden-mtpath="golden-mtpath) - (let* ((duration-since-last-sync (- (current-seconds) last-sync-time))) - (debug:print-info 13 *default-log-port* "duration-since-last-sync="duration-since-last-sync) - (if (and (not *time-to-exit*) - (< duration-since-last-sync sync-cool-off-duration)) - (thread-sleep! (- sync-cool-off-duration duration-since-last-sync))) - (if (not *time-to-exit*) - (let ((golden-mtdb-mtime (file-modification-time golden-mtpath)) - (tmp-mtdb-mtime (file-modification-time tmp-mtpath))) - (if (> golden-mtdb-mtime tmp-mtdb-mtime) - (if (< golden-mtdb-mtime (- (current-seconds) 3)) ;; file has NOT been touched in past three seconds, this way multiple servers won't fight to sync back - (let ((res (db:multi-db-sync dbstruct 'old2new))) - (debug:print-info 13 *default-log-port* "rosync called, " res " records transferred.")))) - (loop (current-seconds))) - #t))) - (debug:print-info 0 *default-log-port* "Exiting readonly-watchdog timer, *time-to-exit* = " *time-to-exit*" pid="(current-process-id)" mtpath="golden-mtpath))) - +;; (define (common:readonly-watchdog dbstruct) +;; (thread-sleep! 0.05) ;; delay for startup +;; (debug:print-info 13 *default-log-port* "common:readonly-watchdog entered.") +;; ;; sync megatest.db to /tmp/.../megatst.db +;; (let* ((sync-cool-off-duration 3) +;; (golden-mtdb (dbr:dbstruct-mtdb dbstruct)) +;; (golden-mtpath (db:dbdat-get-path golden-mtdb)) +;; (tmp-mtdb (dbr:dbstruct-tmpdb dbstruct)) +;; (tmp-mtpath (db:dbdat-get-path tmp-mtdb))) +;; (debug:print-info 0 *default-log-port* "Read-only periodic sync thread started.") +;; (let loop ((last-sync-time 0)) +;; (debug:print-info 13 *default-log-port* "loop top tmp-mtpath="tmp-mtpath" golden-mtpath="golden-mtpath) +;; (let* ((duration-since-last-sync (- (current-seconds) last-sync-time))) +;; (debug:print-info 13 *default-log-port* "duration-since-last-sync="duration-since-last-sync) +;; (if (and (not *time-to-exit*) +;; (< duration-since-last-sync sync-cool-off-duration)) +;; (thread-sleep! (- sync-cool-off-duration duration-since-last-sync))) +;; (if (not *time-to-exit*) +;; (let ((golden-mtdb-mtime (file-modification-time golden-mtpath)) +;; (tmp-mtdb-mtime (file-modification-time tmp-mtpath))) +;; (if (> golden-mtdb-mtime tmp-mtdb-mtime) +;; (if (< golden-mtdb-mtime (- (current-seconds) 3)) ;; file has NOT been touched in past three seconds, this way multiple servers won't fight to sync back +;; (let ((res (db:multi-db-sync dbstruct 'old2new))) +;; (debug:print-info 13 *default-log-port* "rosync called, " res " records transferred.")))) +;; (loop (current-seconds))) +;; #t))) +;; (debug:print-info 0 *default-log-port* "Exiting readonly-watchdog timer, *time-to-exit* = " *time-to-exit*" pid="(current-process-id)" mtpath="golden-mtpath))) +;; ;; Get a lock from the no-sync-db for the from-db, then copy the from-db to the to-db, otherwise return #f (define (db:lock-and-sync no-sync-db from-db to-db) (assert (not *db-sync-in-progress*) "FATAL: db:lock-and-sync called while a sync is in progress.")