From f2e2ca7a074f4b05c77f3c9f4362091b64c1b8e5 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 23 Aug 2023 12:19:22 +0100 Subject: [PATCH] Use the connection pool for build events I'm not sure why this wasn't the way it worked previously. This should avoid unconstrained use of PostgreSQL connections. --- .../web/build-server/controller.scm | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/guix-data-service/web/build-server/controller.scm b/guix-data-service/web/build-server/controller.scm index ca03284..911e41d 100644 --- a/guix-data-service/web/build-server/controller.scm +++ b/guix-data-service/web/build-server/controller.scm @@ -121,23 +121,21 @@ (define (spawn-fiber-for-handler handler) (spawn-fiber (lambda () - (with-postgresql-connection - "build-event-handler-conn" - (lambda (conn) - (with-exception-handler - (lambda (exn) - (simple-format - (current-error-port) - "exception in build event handler: ~A\n" - exn)) - (lambda () - (with-throw-handler #t - (lambda () - (handler conn)) - (lambda _ - (display (backtrace) (current-error-port)) - (display "\n" (current-error-port))))) - #:unwind? #t)))))) + (with-resource-from-pool (connection-pool) conn + (with-exception-handler + (lambda (exn) + (simple-format + (current-error-port) + "exception in build event handler: ~A\n" + exn)) + (lambda () + (with-throw-handler #t + (lambda () + (handler conn)) + (lambda _ + (display (backtrace) (current-error-port)) + (display "\n" (current-error-port))))) + #:unwind? #t))))) (define (with-build-ids-for-status data build-ids