Skip to content

A platform for community discussion. Free, open, simple.

Disconnect the pool during failover and fallback.

Guo Xiang Tanfd75e54793b9
diff --git a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb
index 6060089d4d7..1651c93930a 100644
--- a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb
+++ b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb
@@ -98,8 +98,7 @@ class PostgreSQLFallbackHandler
end
def clear_connections
- ActiveRecord::Base.clear_active_connections!
- ActiveRecord::Base.clear_all_connections!
+ ActiveRecord::Base.connection_pool.disconnect
end
private
diff --git a/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rb b/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rb
index 9daf3aace84..cca583c3093 100644
--- a/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rb
+++ b/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rb
@@ -27,7 +27,6 @@ describe ActiveRecord::ConnectionHandling do
let(:postgresql_fallback_handler) { PostgreSQLFallbackHandler.instance }
before do
- skip("Figure out why this test leaks connections")
postgresql_fallback_handler.initialized = true
['default', multisite_db].each do |db|