mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 19:13:39 +08:00
FIX: Can't boot Discourse with a read-only PG connection.
This commit is contained in:
parent
b91a3c12a5
commit
5656e8f366
|
@ -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
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ describe ActiveRecord::ConnectionHandling do
|
|||
let(:postgresql_fallback_handler) { PostgreSQLFallbackHandler.instance }
|
||||
|
||||
before do
|
||||
skip("Figure out why this test leaks connections")
|
||||
postgresql_fallback_handler.initialized = true
|
||||
|
||||
['default', multisite_db].each do |db|
|
||||
|
|
Loading…
Reference in New Issue
Block a user