mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
FIX: Can't boot Discourse with a read-only PG connection.
This commit is contained in:
@ -17,8 +17,10 @@ class PostgreSQLFallbackHandler
|
||||
@initialized = false
|
||||
|
||||
MessageBus.subscribe(DATABASE_DOWN_CHANNEL) do |payload|
|
||||
RailsMultisite::ConnectionManagement.with_connection(payload.data['db']) do
|
||||
clear_connections
|
||||
if @initialized
|
||||
RailsMultisite::ConnectionManagement.with_connection(payload.data['db']) do
|
||||
clear_connections
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -28,14 +30,10 @@ class PostgreSQLFallbackHandler
|
||||
|
||||
@thread = Thread.new do
|
||||
while true do
|
||||
begin
|
||||
thread = Thread.new { initiate_fallback_to_master }
|
||||
thread.join
|
||||
break if synchronize { @masters_down.hash.empty? }
|
||||
sleep 10
|
||||
ensure
|
||||
thread.kill
|
||||
end
|
||||
thread = Thread.new { initiate_fallback_to_master }
|
||||
thread.join
|
||||
break if synchronize { @masters_down.hash.empty? }
|
||||
sleep 10
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user