mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 17:01:09 +08:00
Pause Sidekiq when postgres failovers.
This commit is contained in:
@ -32,7 +32,10 @@ class PostgreSQLFallbackHandler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def master_down=(args)
|
def master_down=(args)
|
||||||
synchronize { @masters_down[namespace] = args }
|
synchronize do
|
||||||
|
@masters_down[namespace] = args
|
||||||
|
Sidekiq.pause! if args
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def master_up(namespace)
|
def master_up(namespace)
|
||||||
@ -53,6 +56,7 @@ class PostgreSQLFallbackHandler
|
|||||||
|
|
||||||
self.master_up(key)
|
self.master_up(key)
|
||||||
Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
|
Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
|
||||||
|
Sidekiq.unpause!
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
logger.warn "#{log_prefix}: Connection to master PostgreSQL server failed with '#{e.message}'"
|
logger.warn "#{log_prefix}: Connection to master PostgreSQL server failed with '#{e.message}'"
|
||||||
|
@ -71,6 +71,7 @@ describe ActiveRecord::ConnectionHandling do
|
|||||||
.to change { Discourse.readonly_mode? }.from(false).to(true)
|
.to change { Discourse.readonly_mode? }.from(false).to(true)
|
||||||
|
|
||||||
expect(postgresql_fallback_handler.master_down?).to eq(true)
|
expect(postgresql_fallback_handler.master_down?).to eq(true)
|
||||||
|
expect(Sidekiq.paused?).to eq(true)
|
||||||
|
|
||||||
with_multisite_db(multisite_db) do
|
with_multisite_db(multisite_db) do
|
||||||
expect(postgresql_fallback_handler.master_down?).to eq(nil)
|
expect(postgresql_fallback_handler.master_down?).to eq(nil)
|
||||||
@ -92,6 +93,7 @@ describe ActiveRecord::ConnectionHandling do
|
|||||||
|
|
||||||
expect(Discourse.readonly_mode?).to eq(false)
|
expect(Discourse.readonly_mode?).to eq(false)
|
||||||
expect(postgresql_fallback_handler.master_down?).to eq(nil)
|
expect(postgresql_fallback_handler.master_down?).to eq(nil)
|
||||||
|
expect(Sidekiq.paused?).to eq(false)
|
||||||
expect(ActiveRecord::Base.connection_pool.connections.count).to eq(0)
|
expect(ActiveRecord::Base.connection_pool.connections.count).to eq(0)
|
||||||
|
|
||||||
skip("Figuring out why the following keeps failing to obtain a connection on Travis")
|
skip("Figuring out why the following keeps failing to obtain a connection on Travis")
|
||||||
|
Reference in New Issue
Block a user