Address issue with failures when creating resource pool resources
All checks were successful
/ test (push) Successful in 1m4s

Previously failures could lead to no resources in the pool, and
waiters which will never get a resource. Retrying here fixes that
issue, although maybe another approach is needed that keeps track of
new resources being created, as that'll allow keeping track of this
when destroying resource pools.
This commit is contained in:
Christopher Baines 2026-01-12 10:50:11 +00:00
parent 094259b049
commit 2770c1ad70

View file

@ -562,6 +562,7 @@
#f
(raise-exception exn)))
(lambda ()
(let loop ()
(with-parallelism-limiter
return-new-resource/parallelism-limiter
(let ((max-size
@ -569,6 +570,7 @@
'max-size))
(size (count-resources resources)))
(unless (>= size max-size)
(let ((success?
(with-exception-handler
(lambda _ #f)
(lambda ()
@ -585,8 +587,18 @@
(let ((new-resource
(start-stack #t (return-new-resource))))
(put-message channel
(list 'add-resource new-resource))))))
#:unwind? #t)))))
(list 'add-resource new-resource)))
#t)))
#:unwind? #t)))
(unless success?
;; TODO Maybe this should be configurable?
(sleep 1)
;; Important to retry here and eventually create
;; a new resource, as there might be waiters
;; stuck waiting for a resource, especially if
;; the pool is empty.
(loop))))))))
#:unwind? #t))))
(define (spawn-fiber-to-destroy-resource resource-id resource-value)