From 646ed87aba2f90ca0a320f04329d75a59547a969 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 12 Jun 2018 12:13:59 +0800 Subject: [PATCH] Clear all connections once master recovers. --- .../connection_adapters/postgresql_fallback_adapter.rb | 1 + .../connection_adapters/postgresql_fallback_adapter_spec.rb | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb index 1651c93930a..5f4f1b95492 100644 --- a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb +++ b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb @@ -80,6 +80,7 @@ class PostgreSQLFallbackHandler self.master_up(key) disable_readonly_mode Sidekiq.unpause! + clear_connections end rescue => e logger.warn "#{log_prefix}: Connection to master PostgreSQL server failed with '#{e.message}'" 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 cca583c3093..1c07fa49398 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 @@ -36,7 +36,6 @@ describe ActiveRecord::ConnectionHandling do after do postgresql_fallback_handler.setup! - postgresql_fallback_handler.clear_connections Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY) end