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 }