Index: dbfile.scm ================================================================== --- dbfile.scm +++ dbfile.scm @@ -1003,47 +1003,59 @@ (set! *db-write-access* (not (dbr:dbdat-read-only dbdat))) ;; (mutex-unlock! *db-open-mutex*) dbdat)) (define dbfile:db-init-proc (make-parameter #f)) + +(define keep-age-param (make-parameter 10)) ;; 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))) (crumbn (conc destdir"/"(current-seconds)"-"uniqn"."(current-process-id)))) - (if (not (file-exists? destdir))(create-directory destdir #t)) + (if (not (file-exists? destdir))(create-directory (conc destdir"/attic") #t)) (let loop ((count 0)) (let* ((currlks (glob (conc destdir"/*"))) (numqrys (length currlks)) - (delayval (cond + (delayval (cond ;; do a droopish curve ((> numqrys 50) (if (> numqrys 50) (for-each (lambda (f) (if (> (- (current-seconds) - (file-modification-time f)) - 10) - (begin - (dbfile:print-err "Removing qif file "f" older than 10 seconds") - (delete-file* f)))) + (handle-exceptions + exn + (current-seconds) ;; file is likely gone, just fake out + (file-modification-time f))) + (keep-age-param)) + (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)))) currlks)) 1) - ((> numqrys 25) 0.25) - ((> numqrys 10) 0.1) + ((> 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" "params) + )) crumbn)) ;; (db:with-db dbstruct run-id sqlite3:exec "select blah fgrom blaz;") ;; r/w is a flag to indicate if the db is modified by this query #t = yes, #f = no ;;