mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 20:12:45 +08:00
FIX: Don't clear connections on the same process.
This commit is contained in:
parent
003df147a5
commit
7c173265d5
|
@ -16,8 +16,8 @@ class PostgreSQLFallbackHandler
|
|||
@mutex = Mutex.new
|
||||
@initialized = false
|
||||
|
||||
MessageBus.subscribe(DATABASE_DOWN_CHANNEL) do |payload|
|
||||
if @initialized
|
||||
MessageBus.subscribe(DATABASE_DOWN_CHANNEL) do |payload, pid|
|
||||
if @initialized && pid != Process.pid
|
||||
RailsMultisite::ConnectionManagement.with_connection(payload.data['db']) do
|
||||
clear_connections
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ class PostgreSQLFallbackHandler
|
|||
synchronize do
|
||||
@masters_down[namespace] = true
|
||||
Sidekiq.pause! if !Sidekiq.paused?
|
||||
MessageBus.publish(DATABASE_DOWN_CHANNEL, db: namespace)
|
||||
MessageBus.publish(DATABASE_DOWN_CHANNEL, db: namespace, pid: Process.pid)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ describe ActiveRecord::ConnectionHandling do
|
|||
after do
|
||||
postgresql_fallback_handler.setup!
|
||||
Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
|
||||
ActiveRecord::Base.unstub(:postgresql_connection)
|
||||
ActiveRecord::Base.establish_connection
|
||||
end
|
||||
|
||||
describe "#postgresql_fallback_connection" do
|
||||
|
@ -53,7 +55,6 @@ describe ActiveRecord::ConnectionHandling do
|
|||
|
||||
context 'when master server is down' do
|
||||
before do
|
||||
|
||||
@replica_connection = mock('replica_connection')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user