Index: common.scm ================================================================== --- common.scm +++ common.scm @@ -43,11 +43,11 @@ ;; DATABASE (define *open-dbs* (vector #f (make-hash-table))) ;; megatestdb run-id-dbs ;; SERVER (define *my-client-signature* #f) -(define *transport-type* 'fs) +(define *transport-type* 'http) (define *megatest-db* #f) (define *rpc:listener* #f) ;; if set up for server communication this will hold the tcp port (define *runremote* (make-hash-table)) ;; if set up for server communication this will hold (define *last-db-access* (current-seconds)) ;; update when db is accessed via server (define *max-cache-size* 0) Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -117,10 +117,11 @@ (let* ((local (dbr:dbstruct-get-local dbstruct)) (toppath (dbr:dbstruct-get-path dbstruct)) (dbpath (conc toppath "/db/" run-id ".db")) (dbexists (file-exists? dbpath)) (inmem (if local #f (db:open-inmem-db))) + (refdb (if local #f (db:open-inmem-db))) (db (sqlite3:open-database dbpath)) (write-access (file-write-access? dbpath)) (handler (make-busy-timeout 136000))) (if (and dbexists (not write-access)) (set! *db-write-access* #f)) ;; only unset so other db's also can use this control @@ -140,10 +141,12 @@ (dbr:dbstruct-set-runvec-val! dbstruct run-id 'inmem db) ;; direct access ... db) (begin (dbr:dbstruct-set-runvec-val! dbstruct run-id 'inmem inmem) (db:sync-tables db:sync-tests-only db inmem) + (dbr:dbstruct-set-runvec-val! dbstruct run-id 'refdb refdb) + (db:sync-tables db:sync-tests-only db refdb) inmem)))))) ;; This routine creates the db. It is only called if the db is not already opened ;; (define (db:open-main dbstruct) ;; (conc *toppath* "/megatest.db") (car *configinfo*))) @@ -173,20 +176,10 @@ ;; Make the dbstruct, setup up auxillary db's and call for main db at least once ;; (define (db:setup run-id #!key (local #f)) (let ((dbstruct (make-dbr:dbstruct path: *toppath* local: local))) (db:get-db dbstruct #f) ;; force one call to main - ;; (if (not sdb:qry) - ;; (begin - ;; (set! sdb:qry (make-sdb:qry (conc *toppath* "/db/strings.db"))) ;; we open the normalization helpers here - ;; (sdb:qry 'setup #f) - ;; ;; Initialize with some known needed strings, NOTE: set this up to only execute on first db initialization - ;; (for-each - ;; (lambda (str) - ;; (sdb:qry 'get-id str)) - ;; (list "" "logs/final.log")))) - ;; (set! *fdb* (filedb:open-db (conc *toppath* "/db/paths.db"))) dbstruct)) ;; Open the classic megatest.db file in toppath ;; (define (db:open-megatest-db) @@ -832,15 +825,15 @@ '("") patts)) comparator))) -;; register a test run with the db -(define (db:register-run dbstruct keyvals runname state status user) - (debug:print 3 "runs:register-run runname: " runname " state: " state " status: " status " user: " user) - (let* ((db (db:get-db dbstruct #f)) - (keys (map car keyvals)) +;; register a test run with the db, this accesses the main.db and does NOT +;; use server api +;; +(define (db:register-run db keyvals runname state status user) + (let* ((keys (map car keyvals)) (keystr (keys->keystr keys)) (comma (if (> (length keys) 0) "," "")) (andstr (if (> (length keys) 0) " AND " "")) (valslots (keys->valslots keys)) ;; ?,?,? ... (allvals (append (list runname state status user) (map cadr keyvals))) Index: db_records.scm ================================================================== --- db_records.scm +++ db_records.scm @@ -8,14 +8,15 @@ ;; |-monitor.db ;; |-sdb.db ;; |-fdb.db ;; |-1.db ;; |-.db +;; (define (make-dbr:dbstruct #!key (path #f)(local #f)) (vector #f ;; the main db (contains runs, test_meta etc.) NOT CACHED IN MEM - (make-hash-table) ;; run-id => [ rundb inmemdb last-mod last-read last-sync ] + (make-hash-table) ;; run-id => [ rundb inmemdb last-mod last-read last-sync refdb ] #f ;; the global string db (use for state, status etc.) path ;; path to database files/megatest area local)) ;; read-only local access ;; @@ -39,12 +40,12 @@ ;; get a rundb vector, create it if not already existing (define (dbr:dbstruct-get-rundb-rec vec run-id) (let* ((dbhash (dbr:dbstruct-get-dbhash vec)) ;; get the runs hash (runvec (hash-table-ref/default dbhash run-id #f))) ;; get the vector for run-id (if (vector? runvec) - runvec ;; rundb inmemdb last-mod last-read last-sync in-use - (let ((nvec (vector #f #f -1 -1 -1 #f))) + runvec ;; rundb inmemdb last-mod last-read last-sync in-use refdb + (let ((nvec (vector #f #f -1 -1 -1 #f #f))) (hash-table-set! dbhash run-id nvec) nvec)))) ;; [ rundb inmemdb last-mod last-read last-sync ] (define-inline (dbr:dbstruct-field-name->num field-name) @@ -53,10 +54,11 @@ ((inmem) 1) ;; the in-memory db ((mtime) 2) ;; last modification time ((rtime) 3) ;; last read time ((stime) 4) ;; last sync time ((inuse) 5) ;; is the db currently in use, #t yes, #f no. + ((refdb) 6) ;; the db used for reference (can be on disk or inmem) (else -1))) ;; get/set rundb fields (define (dbr:dbstruct-get-runvec-val vec run-id field-name) (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)) Index: docs/plan.txt ================================================================== --- docs/plan.txt +++ docs/plan.txt @@ -6,15 +6,26 @@ Note 2: Starting over. Old plan is commented out. Current Items ------------- -ww05 -~~~~ +ww05 - migrate to inmem-db +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Keep as much the same as possible. Add internal reference to almost +eliminate contention on db(s). +. Add internal reference db +. Verify that actions are accessing correct db +.. -runtests - inmem +.. -list-runs - local (but not megatest.db) +.. dashboard - local (but not megatest.db) +. Mirror db to /var/tmp... +. Dashboard read db from per-run db. +. Dashboard read db from /var/tmp . Runs register in tasks table in monitor.db -. Server polls tasks table for next action +. Server polls tasks table for next action (in addition?) . Change run loop to execute in server, triggered by call to polling of tasks table // ww32 // ~~~~ Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -390,12 +390,20 @@ "fs")))) (debug:print 2 "chosen-transport: " chosen-transport " have; config=" transport-from-config ", cmdln=" transport-from-cmdln ", cmdinfo=" transport-from-cmdinfo) (case chosen-transport ((http) (set! *transport-type 'http) - (if run-id (server:ensure-running run-id)) - (client:launch run-id)) + ;; if we have a run-id (why would we?) start the server for that run. + ;; otherwise it is up to other calls to start the server(s) dynamically + (if run-id + (begin + (server:ensure-running run-id) + (client:launch run-id)) + (begin + ;; without run-id we'll start a server for "0" + (server:ensure-running 0) + (client:launch 0)))) (else ;; (fs) (debug:print 0 "ERROR: Should NOT be getting here! fs transport is no longer supported") (set! *transport-type* 'fs) (set! *megatest-db* (make-dbr:dbstruct path: *toppath* local: #t)))))))))) @@ -695,23 +703,26 @@ (if (args:get-arg "-runtests") (general-run-call "-runtests" "run a test" (lambda (target runname keys keyvals) + ;; + ;; May or may not implement it this way ... + ;; ;; Insert this run into the tasks queue - (open-run-close tasks:add tasks:open-db - "runtests" - user - target + ;; (open-run-close tasks:add tasks:open-db + ;; "runtests" + ;; user + ;; target + ;; runname + ;; (args:get-arg "-runtests") + ;; #f)))) + (runs:run-tests target runname (args:get-arg "-runtests") - #f)))) -;; (runs:run-tests target -;; runname -;; (args:get-arg "-runtests") -;; user -;; args:arg-hash)))) + user + args:arg-hash)))) ;;====================================================================== ;; Rollup into a run ;;====================================================================== Index: rmt.scm ================================================================== --- rmt.scm +++ rmt.scm @@ -41,11 +41,13 @@ (case *transport-type* ((fs-aint-here) (debug:print 0 "ERROR: Not yet (re)supported") (exit 1)) ((fs http) - (let* ((connection-info (client:setup run-id)) + ;; if run-id is #f send the request to run-id = 0 server. This will be for main.db + ;; + (let* ((connection-info (client:setup (if run-id run-id 0))) (jparams (db:obj->string params)) ;; (rmt:dat->json-str params)) (res (http-transport:client-api-send-receive connection-info cmd jparams))) (if res (db:string->obj res) ;; (rmt:json-str->dat res) (begin @@ -93,10 +95,14 @@ (define (rmt:sdb-qry qry val run-id) ;; add caching if qry is 'getid or 'getstr (rmt:send-receive 'sdb-qry run-id (list qry val))) +;; NOT COMPLETED +(define (rmt:runtests user run-id testpatt params) + (rmt:send-receive 'runtests run-id testpatt)) + ;;====================================================================== ;; K E Y S ;;====================================================================== ;; These should not require run-id but it is more consistent to have it. @@ -207,12 +213,13 @@ ;;====================================================================== (define (rmt:get-run-info run-id) (rmt:send-receive 'get-run-info run-id (list run-id))) +;; Use the special run-id == #f scenario here since there is no run yet (define (rmt:register-run keyvals runname state status user) - (rmt:send-receive 'register-run (list keyvals runname state status user))) + (rmt:send-receive 'register-run #f (list keyvals runname state status user))) (define (rmt:get-run-name-from-id run-id) (rmt:send-receive 'get-run-name-from-id run-id (list run-id))) (define (rmt:delete-run run-id) Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -201,11 +201,10 @@ ;; test-names: Comma separated patterns same as test-patts but used in selection ;; of tests to run. The item portions are not respected. ;; FIXME: error out if /patt specified ;; (define (runs:run-tests target runname test-patts user flags) ;; test-names - (common:clear-caches) ;; clear all caches (let* ((keys (keys:config-get-fields *configdat*)) (keyvals (keys:target->keyval keys target)) (run-id (rmt:register-run keyvals runname "new" "n/a" user)) ;; test-name))) (deferred '()) ;; delay running these since they have a waiton clause (runconfigf (conc *toppath* "/runconfigs.config")) @@ -1490,10 +1489,11 @@ ;; NOT PORTED - DO NOT USE YET ;; (define (runs:rollup-run keys runname user keyvals) (debug:print 4 "runs:rollup-run, keys: " keys " :runname " runname " user: " user) (let* ((db #f) + ;; register run operates on the main db (new-run-id (rmt:register-run keyvals runname "new" "n/a" user)) (prev-tests (rmt:get-matching-previous-test-run-records new-run-id "%" "%")) (curr-tests (mt:get-tests-for-run new-run-id "%/%" '() '())) (curr-tests-hash (make-hash-table))) (rmt:update-run-event_time new-run-id) Index: server.scm ================================================================== --- server.scm +++ server.scm @@ -138,10 +138,10 @@ ) (begin (debug:print-info 0 "Waiting for server to start") (thread-sleep! 4))) (if (< trycount 10) - (loop (open-run-close tasks:get-best-server tasks:open-db) + (loop (open-run-close tasks:get-server tasks:open-db run-id) (+ trycount 1)) (debug:print 0 "WARNING: Couldn't start or find a server."))) (debug:print 2 "INFO: Server(s) running " servers) )))