Index: dbmod.scm ================================================================== --- dbmod.scm +++ dbmod.scm @@ -450,11 +450,12 @@ ) (debug:print 0 *default-log-port* "Doing sync "direction" "destdbfile) (if (not (sqlite3:auto-committing? dbh)) (debug:print 0 *default-log-port* "Skipping sync due to transaction in flight.") (let* ((table-names (map car tables)) - (dest-exists (file-exists? destdbfile))) + (dest-exists (file-exists? destdbfile)) + (start-time (current-milliseconds))) (assert dest-exists "FATAL: sync called with non-existant file, "destdbfile) ;; attach the destdbfile ;; for each table ;; insert into dest. select * from src.
where last_update>last_update ;; done @@ -487,15 +488,15 @@ ;; (begin (mutex-lock! *db-transaction-mutex*) (sqlite3:with-transaction dbh (lambda () - (debug:print-info 0 *default-log-port* "Sync from "fromdb table" to "todb table" using "stmt1) + (debug:print-info 0 *default-log-port* "Sync from "fromdb table" to "todb table" using INSERT OR UPDATE") (sqlite3:execute dbh stmt1) ;; get all new rows - #;(if (member "last_update" fields) - (sqlite3:execute dbh stmt8)) ;; get all updated rows + (if (member "last_update" fields) + (sqlite3:execute dbh stmt8)) ;; get all updated rows ;; (sqlite3:execute dbh stmt5) ;; (sqlite3:execute dbh stmt4) ;; if it worked this would be better for incremental up ;; (sqlite3:execute dbh stmt6) )) (debug:print 0 *default-log-port* "Synced table "table @@ -502,11 +503,13 @@ " in "(- (current-milliseconds) start-ms)"ms") ;; ) (mutex-unlock! *db-transaction-mutex*))) ;; (debug:print 0 *default-log-port* "Skipping sync of table "table" due to transaction in flight.")))) table-names) - (sqlite3:execute dbh "DETACH auxdb;")))) + (sqlite3:execute dbh "DETACH auxdb;") + (debug:print-info 0 *default-log-port* "Total sync time: "(- (current-milliseconds) start-time)"ms") + -1))) ;; FAILED ATTEMPTS ;; (if (not (has-last-update dbh table)) ;; (sqlite3:execute dbh (conc "ALTER TABLE "table" ADD COLUMN last_update INTEGER;"))) @@ -795,15 +798,16 @@ (define (dbmod:db-to-db-sync src-db dest-db last-update init-proc keys) (if (and (file-exists? src-db) (file-read-access? src-db)) (let* ((d-wr (or (and (file-exists? dest-db) (file-write-access? dest-db)) ;; exists and writable - (let* ((dirname (pathname-directory dest-db))) - (and dirname - (file-exists? dirname) - (file-write-access? dirname))))) + (let* ((dirname (or (pathname-directory dest-db) + "."))) + (if dirname + (file-exists? dirname) + (file-write-access? dirname))))) (tables (db:sync-all-tables-list keys)) (sdb (dbmod:safely-open-db src-db init-proc #t)) (ddb (dbmod:safely-open-db dest-db init-proc d-wr))) (dbmod:sync-gasket tables last-update sdb ddb dest-db 'todest)))) ) Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -1156,16 +1156,20 @@ (let ((cfname (args:get-arg "-append-config"))) (if (and cfname (file-read-access? cfname)) (read-config cfname *configdat* #t))) ;; values are added to the hash, no need to do anything special. ;; have config at this time, this is a good place to set params based on config file settings - (let* ((dbmode (configf:lookup *configdat* "setup" "dbcache-mode"))) + (let* ((dbmode (configf:lookup *configdat* "setup" "dbcache-mode")) + (syncmode (configf:lookup *configdat* "setup" "sync-mode"))) (if dbmode (begin (debug:print-info 0 *default-log-port* "Overriding dbmode to "dbmode) - (dbcache-mode (string->symbol dbmode))))) - + (dbcache-mode (string->symbol dbmode)))) + (if syncmode + (begin + (debug:print-info 0 *default-log-port* "Overriding syncmode to "syncmode) + (dbfile:sync-method (string->symbol syncmode))))) *toppath*))) (define (get-best-disk confdat testconfig) (let* ((disks (or (and testconfig (hash-table-ref/default testconfig "disks" #f)) Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -2565,20 +2565,22 @@ (set! *didsomething* #t))) ;; use with -from and -to ;; (if (args:get-arg "-db2db") - (let* ((duh (launch:setup)) - (src-db (args:get-arg "-from")) - (dest-db (args:get-arg "-to")) - (lockfile (conc dest-db".lock")) + (let* ((duh (launch:setup)) + (src-db (args:get-arg "-from")) + (dest-db (args:get-arg "-to")) + (sync-period (args:get-arg "-period")) ;; NOT IMPLEMENTED YET + (sync-timeout (args:get-arg "-timeout")) ;; NOT IMPLEMENTED YET + (lockfile (conc dest-db".lock")) ;; (locked (common:simple-file-lock lockfile)) - (keys (db:get-keys #f)) + (keys (db:get-keys #f)) (res ;; (if locked - (dbmod:db-to-db-sync src-db dest-db 0 (dbfile:db-init-proc) keys) - ;; #f))) - )) + (dbmod:db-to-db-sync src-db dest-db 0 (dbfile:db-init-proc) keys) + ;; #f))) + )) (if (and src-db dest-db) (begin (debug:print-info 0 *default-log-port* "Attempting to sync data from "src-db" to "dest-db"...") (if res