aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2024-09-08 10:20:21 +0100
committerChristopher Baines <mail@cbaines.net>2024-09-08 10:20:21 +0100
commitaca5f8ca05956011c678fad80219fb2ee9526c98 (patch)
treef3a517e4cbd1e9a1e472a9c651677a43f0d0274a
parentb7ce9fe008de1af20a82aba2108c2897884d90bc (diff)
downloaddata-service-aca5f8ca05956011c678fad80219fb2ee9526c98.tar
data-service-aca5f8ca05956011c678fad80219fb2ee9526c98.tar.gz
Add a new background connection pool
Mostly to constrain the build server event handlers.
-rw-r--r--guix-data-service/web/build-server/controller.scm2
-rw-r--r--guix-data-service/web/controller.scm4
-rw-r--r--guix-data-service/web/server.scm18
3 files changed, 21 insertions, 3 deletions
diff --git a/guix-data-service/web/build-server/controller.scm b/guix-data-service/web/build-server/controller.scm
index 70ee22e..570ae2f 100644
--- a/guix-data-service/web/build-server/controller.scm
+++ b/guix-data-service/web/build-server/controller.scm
@@ -124,7 +124,7 @@
(define (spawn-fiber-for-handler handler)
(spawn-fiber
(lambda ()
- (with-resource-from-pool (connection-pool) conn
+ (with-resource-from-pool (background-connection-pool) conn
(with-exception-handler
(lambda (exn)
(simple-format
diff --git a/guix-data-service/web/controller.scm b/guix-data-service/web/controller.scm
index 8f23af7..c69f9e6 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -75,9 +75,13 @@
make-render-metrics
controller
+ background-connection-pool
connection-pool
reserved-connection-pool))
+(define background-connection-pool
+ (make-parameter #f))
+
(define connection-pool
(make-parameter #f))
diff --git a/guix-data-service/web/server.scm b/guix-data-service/web/server.scm
index 4e48802..4a38a72 100644
--- a/guix-data-service/web/server.scm
+++ b/guix-data-service/web/server.scm
@@ -198,7 +198,21 @@ port. Also, the port used can be changed by passing the --port option.\n"
(primitive-exit 1))
(lambda ()
(parameterize
- ((connection-pool
+ ((background-connection-pool
+ (make-resource-pool
+ (lambda ()
+ (open-postgresql-connection
+ "background"
+ postgresql-statement-timeout))
+ 4
+ #:name "background"
+ #:idle-seconds 5
+ #:destructor
+ (lambda (conn)
+ (close-postgresql-connection conn "background"))
+ #:scheduler priority-scheduler))
+
+ (connection-pool
(make-resource-pool
(lambda ()
(open-postgresql-connection
@@ -246,7 +260,7 @@ port. Also, the port used can be changed by passing the --port option.\n"
(spawn-fiber
(lambda ()
- (with-resource-from-pool (connection-pool) conn
+ (with-resource-from-pool (background-connection-pool) conn
(backfill-guix-revision-package-derivation-distribution-counts
conn)))
request-scheduler)