Guard against too many pool waiters

As I think this is happening when there are an excessive number of requests,
and that in turn causes issues with file descriptor limits.
This commit is contained in:
Christopher Baines 2025-04-27 11:40:44 +01:00
parent cde34344f8
commit ca80a051ff

View file

@ -203,6 +203,9 @@ port. Also, the port used can be changed by passing the --port option.\n"
#:destructor
(lambda (conn)
(close-postgresql-connection conn "web"))
#:default-max-waiters 300
#:default-checkout-timeout (/ postgresql-statement-timeout
1000)
#:scheduler priority-scheduler))
(reserved-connection-pool
@ -263,7 +266,10 @@ port. Also, the port used can be changed by passing the --port option.\n"
(let ((path-components
mime-types
(request->path-components-and-mime-type request)))
(request->path-components-and-mime-type request))
(pool-exn?
(or (resource-pool-timeout-error? exn)
(resource-pool-too-many-waiters-error? exn))))
(case (most-appropriate-mime-type
mime-types
'(text/html application/json))
@ -273,7 +279,9 @@ port. Also, the port used can be changed by passing the --port option.\n"
(render-json `((error . ,(if (%show-error-details)
(simple-format #f "~A" exn)
#f)))
#:code 500)))
#:code (if pool-exn?
503
500))))
(else
(apply
values
@ -281,7 +289,9 @@ port. Also, the port used can be changed by passing the --port option.\n"
(if (%show-error-details)
exn
#f))
#:code 500))))))
#:code (if pool-exn?
503
500)))))))
(lambda ()
(with-exception-handler
(lambda (exn)