From fad9e70353efad1ce879456da66838eaf5393471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Mon, 14 Sep 2020 15:55:18 +0200 Subject: [PATCH] Fix mutex deadlock in setup_connection (#128) Adds auto_release = false in setup_connection to avoid trying to release the connection to the pool before it has been added. --- spec/database_spec.cr | 1 + src/db/database.cr | 1 + 2 files changed, 2 insertions(+) diff --git a/spec/database_spec.cr b/spec/database_spec.cr index e3aeb79..e35a98f 100644 --- a/spec/database_spec.cr +++ b/spec/database_spec.cr @@ -8,6 +8,7 @@ describe DB::Database do db.setup_connection do |cnn| cnn_setup += 1 + cnn.scalar("1").should eq "1" end cnn_setup.should eq(2) diff --git a/src/db/database.cr b/src/db/database.cr index fd7a709..3eb70cb 100644 --- a/src/db/database.cr +++ b/src/db/database.cr @@ -55,6 +55,7 @@ module DB @pool = uninitialized Pool(Connection) # in order to use self in the factory proc @pool = Pool.new(**pool_options) { conn = @driver.build_connection(self).as(Connection) + conn.auto_release = false @setup_connection.call conn conn }