From 32735be5bd5170949c21ad0eb08b15a87c1d11d2 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 1 Jun 2020 13:26:12 +0800 Subject: [PATCH] DEV: Fix publish to message_bus when forcing pg readonly. --- config/initializers/002-rails_failover.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rb index 8085060c2ce..9985ecd520f 100644 --- a/config/initializers/002-rails_failover.rb +++ b/config/initializers/002-rails_failover.rb @@ -18,10 +18,15 @@ if ENV["ACTIVE_RECORD_RAILS_FAILOVER"] def self.enable_pg_force_readonly_mode Discourse.redis.set(PG_FORCE_READONLY_MODE_KEY, 1) + MessageBus.publish(readonly_channel, true) + Site.clear_anon_cache! + true end def self.disable_pg_force_readonly_mode - Discourse.redis.del(PG_FORCE_READONLY_MODE_KEY) + result = Discourse.redis.del(PG_FORCE_READONLY_MODE_KEY) + MessageBus.publish(readonly_channel, false) + result > 0 end end