From edcfee886133d1bcc887a4035bd48f92ab1effd1 Mon Sep 17 00:00:00 2001 From: Jamie Gaskins Date: Sat, 8 Jul 2023 23:10:07 -0400 Subject: [PATCH] Decrement the inflight counter on ConnectionRefused --- src/db/pool.cr | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/db/pool.cr b/src/db/pool.cr index 5a7da49..9cc1de5 100644 --- a/src/db/pool.cr +++ b/src/db/pool.cr @@ -120,8 +120,11 @@ module DB resource = if @idle.empty? if can_increase_pool? @inflight += 1 - r = unsync { build_resource } - @inflight -= 1 + begin + r = unsync { build_resource } + ensure + @inflight -= 1 + end r else unsync { wait_for_available }