FIX: Incorrect subscription in `PostgreSQLFallbackHandler`.

This commit is contained in:
Guo Xiang Tan 2019-01-21 17:36:56 +08:00
parent c5dd4bf5dc
commit 426907cb88
2 changed files with 3 additions and 2 deletions

View File

@ -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.pid
begin
RailsMultisite::ConnectionManagement.with_connection(payload.data['db']) do
clear_connections

View File

@ -81,6 +81,7 @@ describe ActiveRecord::ConnectionHandling do
end.first
expect(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)