Index: common.scm ================================================================== --- common.scm +++ common.scm @@ -56,12 +56,13 @@ (define (stop-the-train) (thread-start! (make-thread (lambda () (let loop () (if (and *toppath* (file-exists? (conc *toppath*"/stop-the-train"))) - (begin - (debug:print 0 *default-log-port* "ERROR: found file "*toppath*"/stop-the-train, exiting immediately") + (let* ((msg (conc "ERROR: found file "*toppath*"/stop-the-train, exiting immediately"))) + (print msg) + (debug:print 0 *default-log-port* msg) (exit 1))) (thread-sleep! 5) (loop)))))) ;; execute thunk, return value. If exception thrown, trap exception, return #f, and emit nonfatal condition note to *default-log-port* . Index: dbfile.scm ================================================================== --- dbfile.scm +++ dbfile.scm @@ -537,11 +537,11 @@ db (lambda () (condition-case (let* ((curr-val (db:no-sync-get/default db keyname #f))) (if curr-val - (match (db:extract-time-identifier curr-val) + (match (db:extract-time-identifier curr-val) ;; result->timestamp, identifier ((timestamp ident) (if (equal? ident identifier) #t ;; this *is* my lock #f)) ;; nope, not my lock (else #f)) ;; nope, not my lock Index: dbmod.scm ================================================================== --- dbmod.scm +++ dbmod.scm @@ -184,37 +184,42 @@ (if (not (file-exists? tmpdir))(create-directory tmpdir)) ;; check if tmpdb already exists, either delete it or ;; add something to the name fname)) (inmem (dbmod:open-inmem-db init-proc - (if (eq? (dbfile:cache-method) 'inmem) - #f - tmpdb) + ;; (if (eq? (dbfile:cache-method) 'inmem) + ;; #f + tmpdb + ;; ) )) (write-access (file-write-access? dbpath)) (db (dbmod:safely-open-db dbfullname init-proc write-access)) (tables (db:sync-all-tables-list keys))) (if (not (and (sqlite3:database? inmem) (sqlite3:database? db))) (begin (debug:print 0 *default-log-port* "ERROR: Failed to properly open "dbfname-in", exiting immediately.") - (exit))) - ;; (assert (sqlite3:database? inmem) "FATAL: open-dbmoddb: inmem is not a db") + (exit))) ;; (assert (sqlite3:database? inmem) "FATAL: open-dbmoddb: inmem is not a db") ;; (assert (sqlite3:database? db) "FATAL: open-dbmoddb: db is not a db") (dbr:dbstruct-inmem-set! dbstruct inmem) (dbr:dbstruct-ondiskdb-set! dbstruct db) (dbr:dbstruct-dbfile-set! dbstruct dbfullname) (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") - (begin + (let* ((sync-cmd (conc "megatest -db2db -from "tmpdb" -to "dbfullname))) (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) - (dbmod:sync-gasket tables last-update inmem db - dbfullname syncdir keys) + ;; (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))))) ;; (dbmod:sync-tables tables #f db inmem) ;; (if db @@ -229,10 +234,11 @@ ;; direction: 'fromdest 'todest ;; (define (dbmod:sync-gasket tables last-update inmem dbh dbfname direction keys) (assert (sqlite3:database? inmem) "FATAL: sync-gasket: inmem is not a db") (assert (sqlite3:database? inmem) "FATAL: sync-gasket: dbh is not a db") + (debug:print-info 0 *default-log-port* "dbmod:sync-gasket called with sync-method="(dbfile:sync-method)) (case (dbfile:sync-method) ((none) #f) ((attach) (dbmod:attach-sync tables inmem dbfname direction)) ((newsync) @@ -526,11 +532,11 @@ ;; ;; Idea: youngest in dest is last_update time ;; (define (dbmod:new-sync tables dbh1 dbh2 destdbfile direction #!key (mode 'full)) - (debug:print 0 *default-log-port* "Doing sync "direction" "destdbfile) + (debug:print 0 *default-log-port* "Doing new-sync "direction" "destdbfile) (if (not (sqlite3:auto-committing? dbh1)) (debug:print 0 *default-log-port* "Skipping sync due to transaction in flight.") (let* ((table-names (map car tables)) (dest-exists (file-exists? destdbfile))) (assert dest-exists "FATAL: sync called with non-existant file, "destdbfile) Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -742,10 +742,11 @@ ;; for automated creation of the rollup html file this is a good place... (if (not (equal? item-path "")) (tests:summarize-items run-id test-id test-name #f)) + ;; BUG was this meant to be the antecnt of the if above? (tests:summarize-test run-id test-id) ;; don't force - just update if no ;; Leave a .final-status file for the top level test (tests:save-final-status run-id test-id) (rmt:update-run-stats run-id (rmt:get-raw-run-stats run-id))) ;; end of let* @@ -1155,15 +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) Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -2578,19 +2578,24 @@ (lockfile (conc dest-db".lock")) (keys (db:get-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"...") - (let ((res (dbmod:db-to-db-sync src-db dest-db 0 (dbfile:db-init-proc) keys))) - (if res - (debug:print 0 *default-log-port* "Synced " res " records from "src-db" to "dest-db) - (debug:print 0 *default-log-port* "No sync due to permissions or non-existant source db.")))) - (debug:print 0 *default-log-port* "Skipping sync, there is a sync in progress.")) - (set! *didsomething* #t)) - (debug:print 0 *default-log-port* "Usage for -db2db; -to and -from must be specified")) + (if (file-exists? src-db) + (begin + (debug:print-info 0 *default-log-port* "Attempting to sync data from "src-db" to "dest-db"...") + (if (not (file-exists? dest-db)) + (begin + (debug:print 0 *default-log-port* "Using copy to create "dest-db" from "src-db) + (file-copy src-db dest-db)) + (let ((res (dbmod:db-to-db-sync src-db dest-db 0 (dbfile:db-init-proc) keys))) + (if res + (debug:print-info 0 *default-log-port* "Synced " res " records from "src-db" to "dest-db) + (debug:print-info 0 *default-log-port* "No sync due to permissions or other issue."))))) + (debug:print 0 *default-log-port* "No sync due to unreadble or non-existant source file"src-db)) + (debug:print 0 *default-log-port* "Usage for -db2db; -to and -from must be specified")) + (set! *didsomething* #t))) (if (args:get-arg "-list-test-time") (let* ((toppath (launch:setup))) (task:get-test-times) (set! *didsomething* #t))) Index: tcp-transportmod.scm ================================================================== --- tcp-transportmod.scm +++ tcp-transportmod.scm @@ -516,11 +516,14 @@ (let* ((res (if db-locked-in #t (let* ((success (dbfile:with-no-sync-db nosyncdbpath (lambda (db) - (db:no-sync-get-lock-with-id db dbfname (tt-servinf-file ttdat)))))) + (db:no-sync-get-lock-with-id db dbfname + ;; (tt-servinf-file ttdat) ;; does NOT work, must be unique to the dbname which seems silly but makes sense! + areapath ;; as good as anything + ))))) (if success (begin (tt-state-set! ttdat 'running) (debug:print 0 *default-log-port* "Got server lock for " dbfname)