Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -407,29 +407,37 @@ ;; (apply proc cache-db params) ;; )))) - (define (db:all-db-sync dbstruct) (let* ((dbdat (db:open-db dbstruct #f db:initialize-main-db)) (data-synced 0) ;; count of changed records (tmp-area (common:get-db-tmp-area)) (dbfiles (glob (conc tmp-area"/.megatest/*.db"))) (sync-durations (make-hash-table)) (no-sync-db (db:open-no-sync-db))) (for-each - (lambda (file) + (lambda (file) ;; tmp db file (debug:print-info 3 *default-log-port* "file: " file) - (let* ((fname (conc (pathname-file file) ".db")) - (fulln (conc *toppath*"/.megatest/"fname)) - (time1 (if (file-exists? file) - (file-modification-time file) + (let* ((fname (conc (pathname-file file) ".db")) ;; fname is tmp db file + (wal-file (conc fname "-wal")) + (shm-file (conc fname "-shm")) + (fulln (conc *toppath*"/.megatest/"fname)) ;; fulln is nfs db name + (wal-time (if (file-exists? wal-file) + (file-modification-time wal-file) + 0)) + (shm-time (if (file-exists? shm-file) + (file-modification-time shm-file) + 0)) + + (time1 (if (file-exists? file) ;; time1 is the max itime of the tmp db, -wal and -shm files. + (max (file-modification-time file) wal-time shm-time) (begin (debug:print-info 2 *default-log-port* "Sync - I do not see file "file) 1))) - (time2 (if (file-exists? fulln) + (time2 (if (file-exists? fulln) ;; time2 is nfs file time (file-modification-time fulln) (begin (debug:print-info 2 *default-log-port* "Sync - I do not see file "fulln) 0))) (changed (> (- time1 time2) (+ (random 5) 1))) ;; it has been at some few seconds since last synced @@ -458,10 +466,11 @@ (debug:print-info 3 *default-log-port* "skipping sync. " file " is up to date") ))) dbfiles) (if dbdat (dbfile:add-dbdat dbstruct #f dbdat))) #t) + ;; options: ;; ;; 'killservers - kills all servers ;; 'dejunk - removes junk records