From ce95cd22575bcd533bf34b8d99014591012baa50 Mon Sep 17 00:00:00 2001 From: Jamie Gaskins Date: Mon, 10 Jul 2023 09:55:35 -0400 Subject: [PATCH] Decrement the inflight counter on ConnectionRefused (#184) --- 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 }