A platform for community discussion. Free, open, simple.
FIX: Incorrect subscription in `PostgreSQLFallbackHandler`.
Guo Xiang Tan426907cb8812
diff --git a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rbindex 4c3ba60f9d3..7b837119ea2 100644--- a/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb+++ b/lib/active_record/connection_adapters/postgresql_fallback_adapter.rb@@ -16,8 +16,8 @@ class PostgreSQLFallbackHandler@mutex = Mutex.new@initialized = false- MessageBus.subscribe(DATABASE_DOWN_CHANNEL) do |payload, pid|- if @initialized && pid != Process.pid+ MessageBus.subscribe(DATABASE_DOWN_CHANNEL) do |payload|+ if @initialized && payload.data["pid"].to_i != Process.pidbeginRailsMultisite::ConnectionManagement.with_connection(payload.data['db']) doclear_connectionsdiff --git a/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rb b/spec/components/active_record/connection_adapters/postgresql_fallback_adapter_spec.rbindex 56036099858..23b303219b3 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@@ -81,6 +81,7 @@ describe ActiveRecord::ConnectionHandling doend.firstexpect(message.data[:db]).to eq('default')+ expect(message.data[:pid]).to eq(Process.pid)expect { ActiveRecord::Base.postgresql_fallback_connection(config) }.to change { Discourse.readonly_mode? }.from(false).to(true)