Index: dbfile.scm ================================================================== --- dbfile.scm +++ dbfile.scm @@ -44,10 +44,16 @@ (define keep-age-param (make-parameter 10)) ;; qif file age, if over move to attic (define num-run-dbs (make-parameter 10)) ;; number of db's in .megatest (define dbfile:testsuite-name (make-parameter #f)) +;; 'original - use old condition code +;; 'suicide-mode - create mtrah/stop-the-train with info on what went wrong +;; else use no condition code (should be production mode) +;; +(define no-condition-db-with-db (make-parameter 'suicide-mode)) + ;;====================================================================== ;; R E C O R D S ;;====================================================================== ;; a single Megatest area with it's multiple dbs is @@ -1043,12 +1049,10 @@ (lambda () (print fname" run-id="run-id" params="params) )) crumbn)) -(define no-condition-db-with-db (make-parameter #t)) - ;; (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 ;; (define (dbfile:with-db dbstruct run-id r/w proc params) (assert dbstruct "FATAL: db:with-db called with dbstruct "#f) @@ -1071,36 +1075,53 @@ (if use-mutex (mutex-unlock! *db-with-db-mutex*)) ;; (if (vector? dbstruct)(db:done-with dbstruct run-id r/w)) (if dbdat (dbfile:add-dbdat dbstruct run-id dbdat)) ;; (delete-file* crumbfile) - res)))) + res))) + (stop-train (conc (dbr:dbstruct-areapath dbstruct)"/stop-the-train"))) - (assert (sqlite3:database? db) "FATAL: db:with-db, db is not a database, db="db", fname="fname) + (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))) (if (and use-mutex (common:low-noise-print 120 "over-50-parallel-api-requests")) - (dbfile:print-err *api-process-request-count* " parallel api requests being processed in process " + (dbfile:print-err *api-process-request-count* + " parallel api requests being processed in process " (current-process-id))) ;; ", throttling access")) - (if (no-condition-db-with-db) - (qryproc) - (condition-case - (qryproc) - (exn (io-error) - (db:generic-error-printout exn "ERROR: i/o error with " fname ". Check permissions, disk space etc. and try again.")) - (exn (corrupt) - (db:generic-error-printout exn "ERROR: database " fname " is corrupt. Repair it to proceed.")) - (exn (busy) - (db:generic-error-printout exn "ERROR: database " fname - " is locked. Try copying to another location, remove original and copy back.")) - (exn (permission)(db:generic-error-printout exn "ERROR: database " fname " has some permissions problem.")) - (exn () - (db:generic-error-printout exn "ERROR: Unknown error with database " fname " message: " - ((condition-property-accessor 'exn 'message) exn))))))) + (case (no-condition-db-with-db) + ((production)(qryproc)) + ((suicide-mode) + (handle-exceptions + exn + (with-output-to-file stop-train + (lambda () + (db:generic-error-printout exn "Stop train mode, run-id: "run-id + " params: "params" proc: "proc))) + (qryproc))) + (else + (condition-case + (qryproc) + (exn (io-error) + (db:generic-error-printout exn "ERROR: i/o error with "fname + ". Check permissions, disk space etc. and try again.")) + (exn (corrupt) + (db:generic-error-printout exn "ERROR: database "fname + " is corrupt. Repair it to proceed.")) + (exn (busy) + (db:generic-error-printout exn "ERROR: database "fname + " is locked. Try copying to another location," + " remove original and copy back.")) + (exn (permission)(db:generic-error-printout exn "ERROR: database "fname + " has some permissions problem.")) + (exn () + (db:generic-error-printout exn "ERROR: Unknown error with database "fname + " message: " + ((condition-property-accessor 'exn 'message) exn)))))))) ;;====================================================================== ;; another attempt at a transactionized queue ;;======================================================================