From 1464a58fe49931567bf0ac3d6235d515b78370ff Mon Sep 17 00:00:00 2001 From: Rosa Gutierrez Date: Tue, 6 Jul 2021 22:24:02 +0200 Subject: [PATCH] Check that decorated connection responds to open_transactions before invoking An `ActiveRecord::Base.connection` responds to this but other connections such as for example a Redis client do not. --- lib/makara/connection_wrapper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/makara/connection_wrapper.rb b/lib/makara/connection_wrapper.rb index 51ccf617..17749ab2 100644 --- a/lib/makara/connection_wrapper.rb +++ b/lib/makara/connection_wrapper.rb @@ -44,7 +44,7 @@ def _makara_blacklisted? end def _makara_in_transaction? - @connection && @connection.open_transactions > 0 + @connection && @connection.respond_to?(:open_transactions) && @connection.open_transactions > 0 end # blacklist this node for @config[:blacklist_duration] seconds