Index: dbmod.scm ================================================================== --- dbmod.scm +++ dbmod.scm @@ -107,11 +107,26 @@ ;; MOVE THIS CALL TO INSIDE THE sync-proc CALL (dbr:dbstruct-last-update-set! dbstruct curr-secs) ))) (assert (sqlite3:database? dbh) "FATAL: bad db handle in dbmod:with-db") (if use-mutex (mutex-lock! *db-with-db-mutex*)) - (let* ((res (apply proc dbdat dbh params))) + (let* ((res (let loop ((count 3)) + (condition-case + (apply proc dbdat dbh params) + (exn (busy) + (if (> count 0) + (begin + (debug:print-info 0 *default-log-port* "dbmod:with-db, database is busy, will try "count" more times.") + (thread-sleep! 1) + (loop (- count 1))) + (begin + (debug:print-info 0 *default-log-port* "dbmod:with-db, database is busy, giving up.") + (exit 1)))) + (exn () + (dbfile:print-err exn "ERROR: Unknown error with database for run-id "run-id", message: " + ((condition-property-accessor 'exn 'message) exn)) + (exit 2)))))) (if use-mutex (mutex-unlock! *db-with-db-mutex*)) res))) (define (db:with-db dbstruct run-id w/r proc . params) (dbmod:with-db dbstruct run-id w/r proc params)) @@ -119,11 +134,11 @@ ;; (define (dbmod:open-cachedb-db init-proc dbfullname) (let* ((db (if dbfullname (dbmod:safely-open-db dbfullname init-proc #t) (sqlite3:open-database ":memory:"))) - (handler (sqlite3:make-busy-timeout 3600))) + (handler (sqlite3:make-busy-timeout 136000))) (sqlite3:set-busy-handler! db handler) (init-proc db) db)) (define (dbmod:open-db dbstruct run-id dbinit) Index: tcp-transportmod.scm ================================================================== --- tcp-transportmod.scm +++ tcp-transportmod.scm @@ -783,38 +783,38 @@ (define (tt:start-tcp-server ttdat) (setup-listener-portlogger ttdat) ;; set up tcp-listener (let* ((socket (tt-socket ttdat)) (handler (tt-handler ttdat)) ;; the handler comes from our client setting a handler function (handler-proc (lambda () - (let* ((indat (deserialize)) + (let* ((indat (deserialize)) ;; could use: (thread-terminate! (current-thread)) (result #f) (exn-result #f) (stdout-result (with-output-to-string (lambda () - (let ((res ;; ndle-exceptions - ;; exn - ;; let* ((errdat (condition->list exn))) - ;; (set! exn-result errdat) - ;; (debug:print 0 *default-log-port* "ERROR: handler exception, these are bad, will exit in five seconds.") - ;; (pp errdat *default-log-port*) - ;; ;; these are always bad, set up an exit thread - ;; (thread-start! (make-thread (lambda () - ;; (thread-sleep! 5) - ;; (exit)))) - ;; #f) + (let ((res (handle-exceptions + exn + (let* ((errdat (condition->list exn))) + (set! exn-result errdat) + (debug:print 0 *default-log-port* "ERROR: handler exception, these are bad, will exit in five seconds.") + (pp errdat *default-log-port*) + ;; these are always bad, set up an exit thread + (thread-start! (make-thread (lambda () + (thread-sleep! 5) + (exit)))) + #f) (handler indat) ;; this is the proc being called by the remote client - )) ;; ) + ))) (set! result res))))) - (full-result (list result exn-result (if (equal? stdout-result "") #f stdout-result)))) - ;; (handle-exceptions - ;; exn - ;; (begin - ;; (debug:print 0 *default-log-port* "Serialization failure. full-result="full-result) - ;; ;; (serialize '(#f #f #f)) ;; doesn't work - the first call to serialize caused failure - ;; - ;; ) - (serialize full-result))))) ;; ) + (full-result (list result exn-result (if (equal? stdout-result "") #f stdout-result)))) + (handle-exceptions + exn + (begin + (debug:print 0 *default-log-port* "Serialization failure. full-result="full-result) + (thread-start! (make-thread (lambda () + (thread-sleep! 5) + (exit))))) ;; (serialize '(#f #f #f)) ;; doesn't work - the first call to serialize caused failure + (serialize full-result)))))) ((make-tcp-server socket handler-proc) #f ;; yes, send error messages to std-err ))) ;; create a tcp listener and return a populated udat struct with