Index: api.scm ================================================================== --- api.scm +++ api.scm @@ -190,11 +190,15 @@ (readonly-command (member cmd api:read-only-queries)) (writecmd-in-readonly-mode (and readonly-mode (not readonly-command)))) (if (not readonly-command) (mutex-lock! write-mutex)) (let* ((tmppath (dbr:dbstruct-tmppath dbstruct)) - (crumbfile (dbfile:wait-for-qif tmppath run-id (cons cmd params))) + (clean-run-id (cond + ((number? run-id) run-id) + ((equal? run-id #f) "main") + (else "other"))) + (crumbfile (dbfile:wait-for-qif tmppath clean-run-id (cons cmd params))) (res (if writecmd-in-readonly-mode (conc "attempt to run write command "cmd" on a read-only database") (api:dispatch-request dbstruct cmd run-id params)))) (delete-file* crumbfile) Index: dbfile.scm ================================================================== --- dbfile.scm +++ dbfile.scm @@ -1005,18 +1005,19 @@ dbdat)) (define dbfile:db-init-proc (make-parameter #f)) (define keep-age-param (make-parameter 10)) +(define qif-slope (make-parameter 100)) ;; create a dropping near the db file in a qif dir ;; use count of such files to gate queries (queries in flight) ;; (define (dbfile:wait-for-qif fname run-id params) (let* ((thedir (pathname-directory fname)) - (destdir (conc thedir"/qif")) - (uniqn (get-area-path-signature (conc run-id params))) + (destdir (conc thedir"/qif-"run-id)) + (uniqn (get-area-path-signature (conc (or run-id "main") params))) (crumbn (conc destdir"/"(current-seconds)"-"uniqn"."(current-process-id)))) (if (not (file-exists? destdir))(create-directory (conc destdir"/attic") #t)) (let loop ((count 0)) (let* ((currlks (glob (conc destdir"/*"))) (numqrys (length currlks)) @@ -1034,27 +1035,31 @@ (let* ((basedir (pathname-directory f)) (filen (pathname-file f)) (destf (conc basedir"/attic/"filen))) (dbfile:print-err "Moving qif file "f" older than 10 seconds to "destf) ;; (delete-file* f) - (file-move f destf #t)))) + (handle-exceptions + exn + #t + (file-move f destf #t))))) currlks)) - 1) - ((> numqrys 30) 0.50) - ((> numqrys 25) 0.20) - ((> numqrys 20) 0.10) - ((> numqrys 15) 0.05) - ((> numqrys 10) 0.01) + 1) ;; 50 and above => 1 + ((> numqrys 10) (* numqrys (/ 1 (qif-slope)))) ;; slope of 1/100 + ;; ((> numqrys 30) 0.50) + ;; ((> numqrys 25) 0.20) + ;; ((> numqrys 20) 0.10) + ;; ((> numqrys 15) 0.05) + ;; ((> numqrys 10) 0.01) (else #f)))) (if (and delayval (< count 5)) (begin (thread-sleep! delayval) (loop (+ count 1)))))) (with-output-to-file crumbn (lambda () - (print fname" "run-id" "params) + (print fname" run-id="run-id" params="params) )) crumbn)) (define no-condition-db-with-db (make-parameter #t)) @@ -1084,11 +1089,10 @@ (if dbdat (dbfile:add-dbdat dbstruct run-id dbdat)) ;; (delete-file* crumbfile) res)))) - ;; (crumbfile (dbfile:wait-for-qif fname run-id params))) (assert (sqlite3:database? db) "FATAL: db:with-db, db is not a database, db="db", fname="fname) (if (file-exists? jfile) (begin (dbfile:print-err "INFO: "jfile" exists, delaying to reduce database load") (thread-sleep! 0.2))) Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -314,11 +314,11 @@ (debug:print-error 0 *default-log-port* "Nothing to kill, pid1=" pid1 ", pid2=" pid2) (tests:test-set-status! run-id test-id "KILLED" "FAILED TO KILL" (conc (args:get-arg "-m")" "kill-reason) #f) ;; BB ADDED kill-reason -- confirm OK with Matt ))) (mutex-unlock! m) ;; no point in sticking around. Exit now. But run end of run before exiting? - (launch:end-of-run-check run-id) + (launch:end-of-run-check run-id) (exit))) (if (hash-table-ref/default misc-flags 'keep-going #f) (begin (thread-sleep! 3) ;; (+ 3 (random 6))) ;; add some jitter to the call home time to spread out the db accesses (if (hash-table-ref/default misc-flags 'keep-going #f) ;; keep originals for cpu-load and disk-free unless they change more than the allowed delta