Changes In Branch v1.64-locked-records Excluding Merge-Ins
This is equivalent to a diff from 18835703e2 to 7dbb46b417
2017-08-03
| ||
22:13 | Comment Closed-Leaf check-in: 7dbb46b417 user: matt tags: v1.64-locked-records | |
2017-07-24
| ||
16:48 | added adaptive dashboard poll interval check-in: 2c254ec7e0 user: bjbarcla tags: v1.64 | |
2017-07-23
| ||
23:02 | Beginings of locked records being moved to alt db. check-in: 7b033579f4 user: matt tags: v1.64-locked-records | |
2017-07-21
| ||
16:25 | Fixed missing condition where exit on no start needed for server was happening. check-in: 18835703e2 user: mrwellan tags: v1.64 | |
11:11 | Added a little code to move server logs aside in the case where the server decided to not start check-in: 2efebe79cc user: mrwellan tags: v1.64 | |
Modified db.scm from [5cc0abc545] to [bffce543ab].
︙ | ︙ | |||
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | (tmpdb #f) (dbstack #f) ;; stack for tmp db handles, do not initialize with a stack (mtdb #f) (refndb #f) (homehost #f) ;; not used yet (on-homehost #f) ;; not used yet (read-only #f) ) ;; goal is to converge on one struct for an area but for now it is too confusing ;; record for keeping state,status and count for doing roll-ups in ;; iterated tests ;; (defstruct dbr:counts (state #f) (status #f) | > > > > > > > > > > > > > > > | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | (tmpdb #f) (dbstack #f) ;; stack for tmp db handles, do not initialize with a stack (mtdb #f) (refndb #f) (homehost #f) ;; not used yet (on-homehost #f) ;; not used yet (read-only #f) ;; db-type: ;; 'local => normal, local, area ;; 'locked => locked runs ;; 'alt-area => db for another area (db-type 'local) (other-dbs (make-hash-table)) ;; hash-table of other dbdats, foo => (db . dbpath)) ... (current-other #f) ;; use this to set *which* other db to use in various calls ) ;; goal is to converge on one struct for an area but for now it is too confusing (define (dbr:dbstruct-add-other-db dbstruct area-name db) (dbr:dbstruct-other-db-set! dbstruct (hash-table-set! (dbr:dbstruct-other-dbs dbstruct) area-name (cons area-name db)))) (define (dbr:dbstruct-lookup-other-db dbstruct area-name) (hash-table-ref/default (dbr:dbstruct-other-dbs dbstruct) area-name #f)) ;; record for keeping state,status and count for doing roll-ups in ;; iterated tests ;; (defstruct dbr:counts (state #f) (status #f) |
︙ | ︙ | |||
91 92 93 94 95 96 97 | ;; Get/open a database ;; if run-id => get run specific db ;; if #f => get main db ;; if db already open - return inmem ;; if db not open, open inmem, rundb and sync then return inmem ;; inuse gets set automatically for rundb's ;; | | > > | | | | | | | > > > > > > > > > > > > > > > > > > > > > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | ;; Get/open a database ;; if run-id => get run specific db ;; if #f => get main db ;; if db already open - return inmem ;; if db not open, open inmem, rundb and sync then return inmem ;; inuse gets set automatically for rundb's ;; (define (db:get-db dbstruct #!key (alt-db #f)) ;; run-id) (case (dbr:dbstruct-db-type dbstruct) ((local) (if (stack? (dbr:dbstruct-dbstack dbstruct)) (if (stack-empty? (dbr:dbstruct-dbstack dbstruct)) (let ((newdb (db:open-megatest-db path: (db:dbfile-path)))) ;; (stack-push! (dbr:dbstruct-dbstack dbstruct) newdb) newdb) (stack-pop! (dbr:dbstruct-dbstack dbstruct))) (db:open-db dbstruct))) ((locked) (let* ((current-other (dbr:dbstruct-current-other dbstruct)) ;; contains the name of the current "other" db to work with (locked-db (dbr:dbstruct-lookup-other-db dbstruct current-other))) (if locked-db locked-db ;; problem here is we don't know which locked db to open (let* ((link-tree (common:get-link-tree)) (dbdir (conc link-tree "/.db")) ;; sure, let's use the old .db dir (dbdat (db:open-megatest-db path: dbdir name: (conc (time->string (seconds->local-time sec) "%Y") "-q" (seconds->quarter sec) ".db")))) (hash-table-set! (dbr:dbstruct-other-dbs dbstruct) current-other dbdat) dbdat)))) (else ;; we should NEVER get here. Exit with message. (with-output-to-port *default-log-port* print-call-chain) (debug:print 0 *default-log-port* "ERROR: bad call to db:get-db, dbstruct contents:") (with-output-to-port *default-log-port* (lambda () (pp (dbr:dbstruct->alist dbstruct))))))) ;; ;; legacy handling of structure for managing db's. Refactor this into dbr:? (define (db:dbdat-get-db dbdat) (if (pair? dbdat) (car dbdat) dbdat)) |
︙ | ︙ | |||
161 162 163 164 165 166 167 | (if dbdat (stack-push! (dbr:dbstruct-dbstack dbstruct) dbdat)) res)))) ;;====================================================================== ;; K E E P F I L E D B I N dbstruct ;;====================================================================== | < < < < < < < < < < < < < < < < < < < < < < < < < | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | (if dbdat (stack-push! (dbr:dbstruct-dbstack dbstruct) dbdat)) res)))) ;;====================================================================== ;; K E E P F I L E D B I N dbstruct ;;====================================================================== (define db:dbfile-path common:get-db-tmp-area) (define (db:set-sync db) (let ((syncprag (configf:lookup *configdat* "setup" "sychronous"))) (sqlite3:execute db (conc "PRAGMA synchronous = " (or syncprag 0) ";")))) ;; open an sql database inside a file lock |
︙ | ︙ | |||
254 255 256 257 258 259 260 | (exn (corrupt) (debug:print 0 *default-log-port* "ERROR: database " fname " is corrupt. Repair it to proceed.")) (exn (busy) (debug:print 0 *default-log-port* "ERROR: database " fname " is locked. Try copying to another location, remove original and copy back.")) (exn (permission)(debug:print 0 *default-log-port* "ERROR: database " fname " has some permissions problem.")) (exn () (debug:print 0 *default-log-port* "ERROR: Unknown error with database " fname " message: " ((condition-property-accessor 'exn 'message) exn)))) ))) | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | (exn (corrupt) (debug:print 0 *default-log-port* "ERROR: database " fname " is corrupt. Repair it to proceed.")) (exn (busy) (debug:print 0 *default-log-port* "ERROR: database " fname " is locked. Try copying to another location, remove original and copy back.")) (exn (permission)(debug:print 0 *default-log-port* "ERROR: database " fname " has some permissions problem.")) (exn () (debug:print 0 *default-log-port* "ERROR: Unknown error with database " fname " message: " ((condition-property-accessor 'exn 'message) exn)))) ))) ;; This routine creates the db if not already present. It is only called if the db is not already opened ;; (define (db:open-db dbstruct #!key (areapath #f)(do-sync #t)) ;; TODO: actually use areapath (let ((tmpdb-stack (dbr:dbstruct-dbstack dbstruct))) ;; RA => Returns the first reference in dbstruct (if (stack? tmpdb-stack) (db:get-db tmpdb-stack) ;; get previously opened db (will create new db handle if all in the stack are already used (let* ((dbpath (db:dbfile-path )) ;; path to tmp db area |
︙ | ︙ | |||
382 383 384 385 386 387 388 389 390 391 392 393 394 395 | ;;(db:initialize-run-id-db db) ))) (write-access (file-write-access? dbpath))) (debug:print-info 13 *default-log-port* "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 ;; (define (db:sync-touched dbstruct run-id #!key (force-sync #f)) (let ((tmpdb (db:get-db dbstruct)) (mtdb (dbr:dbstruct-mtdb dbstruct)) (refndb (dbr:dbstruct-refndb dbstruct)) | > | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | ;;(db:initialize-run-id-db db) ))) (write-access (file-write-access? dbpath))) (debug:print-info 13 *default-log-port* "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 ;; (define (db:sync-touched dbstruct run-id #!key (force-sync #f)) (let ((tmpdb (db:get-db dbstruct)) (mtdb (dbr:dbstruct-mtdb dbstruct)) (refndb (dbr:dbstruct-refndb dbstruct)) |
︙ | ︙ |