From b8de8ecb4b29b81d8316a18b0c133a23725bf44d Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Wed, 19 Jul 2023 22:20:18 -0300 Subject: [PATCH] Fix race condition --- 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 9cc1de5..b88c109 100644 --- a/src/db/pool.cr +++ b/src/db/pool.cr @@ -200,8 +200,11 @@ module DB end end - if idle_pushed && are_waiting_for_resource? - @availability_channel.send nil + if idle_pushed + select + when @availability_channel.send(nil) + else + end end end