Index: common.scm ================================================================== --- common.scm +++ common.scm @@ -702,18 +702,19 @@ (define (common:watchdog) ;;#t) (BB> "common:watchdog entered.") (let ((dbstruct (db:setup))) - (cond - ((dbr:dbstruct-read-only dbstruct) - (BB> "loading read-only watchdog") - (common:readonly-watchdog dbstruct)) - (else - (BB> "loading writable-watchdog.") - (common:writable-watchdog dbstruct)))) - (BB> "watchdog done.");;) + (BB> "after db:setup with dbstruct="dbstruct) + (cond + ((dbr:dbstruct-read-only dbstruct) + (BB> "loading read-only watchdog") + (common:readonly-watchdog dbstruct)) + (else + (BB> "loading writable-watchdog.") + (common:writable-watchdog dbstruct)))) + (BB> "watchdog done.");;) ) (define (std-exit-procedure) (on-exit (lambda () 0)) Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -285,22 +285,25 @@ (mtdbexists (file-exists? mtdbpath)) (refndb (db:open-megatest-db path: dbpath name: "megatest_ref.db")) (write-access (file-write-access? mtdbpath))) ;;(BB> "db:open-db>> mtdbpath="mtdbpath" mtdbexists="mtdbexists" and write-access="write-access) (if (and dbexists (not write-access)) - (begin (set! *db-write-access* #f) - (dbr:dbstruct-read-only-set! dbstruct #t))) + (begin + (set! *db-write-access* #f) + (dbr:dbstruct-read-only-set! dbstruct #t))) (dbr:dbstruct-mtdb-set! dbstruct mtdb) (dbr:dbstruct-tmpdb-set! dbstruct tmpdb) (dbr:dbstruct-dbstack-set! dbstruct (make-stack)) ;; BB: why a stack? Why would the number of db's be indeterminate? Is this a legacy of 1.db 2.db .. ? (stack-push! (dbr:dbstruct-dbstack dbstruct) tmpdb) ;; olddb is already a (cons db path) (dbr:dbstruct-refndb-set! dbstruct refndb) ;; (mutex-unlock! *rundb-mutex*) - (if (not dbfexists) + (if #t ;;(not dbfexists) (begin (debug:print 0 *default-log-port* "filling db " (db:dbdat-get-path tmpdb) " with data from " (db:dbdat-get-path mtdb)) - (db:sync-tables (db:sync-all-tables-list dbstruct) #f mtdb refndb tmpdb)) + (db:sync-tables (db:sync-all-tables-list dbstruct) #f mtdb refndb tmpdb) + (BB> "db:sync-all-tables-list done.") + ) (debug:print 0 *default-log-port* " db, " (db:dbdat-get-path tmpdb) " already exists, not propogating data from " (db:dbdat-get-path mtdb))) ;; (db:multi-db-sync dbstruct 'old2new)) ;; migrate data from megatest.db automatically tmpdb)))) ;; Make the dbstruct, setup up auxillary db's and call for main db at least once @@ -307,18 +310,22 @@ ;; ;; called in http-transport and replicated in rmt.scm for *local* access. ;; (define (db:setup #!key (areapath #f)) ;; + (cond (*dbstruct-db* *dbstruct-db*);; TODO: when multiple areas are supported, this optimization will be a hazard (else ;;(common:on-homehost?) + (BB> "db:setup entered (first time, not cached.)") (let* ((dbstruct (make-dbr:dbstruct))) (when (not *toppath*) (BB> "in db:setup, *toppath* not set; calling launch:setup") (launch:setup areapath: areapath)) + (BB> "Begin db:open-db") (db:open-db dbstruct areapath: areapath) + (BB> "Done db:open-db") (set! *dbstruct-db* dbstruct) ;;(BB> "new dbstruct = "(dbr:dbstruct->alist dbstruct)) dbstruct)))) ;; (else ;; (debug:print 0 *default-log-port* "ERROR: attempt to open database when not on homehost. Exiting. Homehost: " (common:get-homehost)) @@ -334,10 +341,11 @@ (db (db:lock-create-open dbpath (lambda (db) (db:initialize-main-db db) (db:initialize-run-id-db db)))) (write-access (file-write-access? dbpath))) + (BB> "db:open-megatest-db "dbpath) (if (and dbexists (not write-access)) (set! *db-write-access* #f)) (cons db dbpath))) ;; sync run to disk if touched @@ -622,11 +630,11 @@ (full-ins (conc "INSERT OR REPLACE INTO " tablename " ( " (string-intersperse (map car fields) ",") " ) " " VALUES ( " (string-intersperse (make-list num-fields "?") ",") " );")) (fromdat '()) (fromdats '()) (totrecords 0) - (batch-len (string->number (or (configf:lookup *configdat* "sync" "batchsize") "10"))) + (batch-len (string->number (or (configf:lookup *configdat* "sync" "batchsize") "100"))) (todat (make-hash-table)) (count 0)) ;; set up the field->num table (for-each