diff --git a/guix-data-service/web/server.scm b/guix-data-service/web/server.scm index d1b1284..9e20118 100644 --- a/guix-data-service/web/server.scm +++ b/guix-data-service/web/server.scm @@ -235,55 +235,58 @@ port. Also, the port used can be changed by passing the --port option.\n" (while (not (check-startup-completed startup-completed)) (sleep 1)) - (with-exception-handler - (lambda _ #f) - (lambda () + (while (with-exception-handler - (lambda (exn) - (simple-format - #t - "exception when processing the background jobs queue") - (print-backtrace-and-exception/knots - exn) - (raise-exception exn)) + (lambda _ #t) (lambda () - (let ((build-ids - (call-with-resource-from-pool (background-connection-pool) - (lambda (conn) - (select-background-processing-build-ids conn))))) - (unless (null? build-ids) - (simple-format #t "processing ~A builds from the background queue\n" - (length build-ids))) - (fibers-batch-for-each - (lambda (build-id) - (call-with-resource-from-pool (background-connection-pool) - (lambda (conn) - (let ((status (select-latest-build-status-by-build-id - conn - build-id))) - (cond - ((string=? status "succeeded") - (handle-removing-blocking-build-entries-for-successful-builds - conn - (list build-id))) - ((string=? status "scheduled") - (handle-blocked-builds-entries-for-scheduled-builds - conn - (list build-id))) - ((member status '("failed" - "failed-dependency" - "canceled")) - (handle-populating-blocked-builds-for-build-failures + (with-exception-handler + (lambda (exn) + (simple-format + #t + "exception when processing the background jobs queue") + (print-backtrace-and-exception/knots + exn) + (raise-exception exn)) + (lambda () + (let ((build-ids + (call-with-resource-from-pool (background-connection-pool) + (lambda (conn) + (select-background-processing-build-ids conn))))) + (unless (null? build-ids) + (simple-format #t "processing ~A builds from the background queue\n" + (length build-ids))) + (fibers-batch-for-each + (lambda (build-id) + (call-with-resource-from-pool (background-connection-pool) + (lambda (conn) + (let ((status (select-latest-build-status-by-build-id + conn + build-id))) + (cond + ((string=? status "succeeded") + (handle-removing-blocking-build-entries-for-successful-builds + conn + (list build-id))) + ((string=? status "scheduled") + (handle-blocked-builds-entries-for-scheduled-builds + conn + (list build-id))) + ((member status '("failed" + "failed-dependency" + "canceled")) + (handle-populating-blocked-builds-for-build-failures + conn + (list build-id))))) + (delete-background-processing-entries-for-build-ids conn (list build-id))))) - (delete-background-processing-entries-for-build-ids - conn - (list build-id))))) - (assq-ref (resource-pool-stats (background-connection-pool) - #:timeout #f) - 'resources) - build-ids))))) - #:unwind? #t)) + (assq-ref (resource-pool-stats (background-connection-pool) + #:timeout #f) + 'resources) + build-ids)) + #f))) + #:unwind? #t) + (sleep 20))) #:parallel? #t) (spawn-fiber