From 031a6616a3400ddb3f5da5298d029aaf25db8447 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 21 Jul 2020 12:32:50 +0800 Subject: [PATCH] DEV: Allow writes to PG even if Redis is readonly mode. Previously, I thought it was better to drop the site into reading mode when Redis has failed over to the replica but it created more errors while Redis is in readonly mode since ActiveRecord would prevent us from writing to PG even though PG is up. --- config/initializers/002-rails_failover.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rb index e4a80709f9c..0bfa3d9f2bf 100644 --- a/config/initializers/002-rails_failover.rb +++ b/config/initializers/002-rails_failover.rb @@ -55,16 +55,12 @@ if defined?(RailsFailover::ActiveRecord) Discourse.redis.exists?( Discourse::PG_READONLY_MODE_KEY, Discourse::PG_FORCE_READONLY_MODE_KEY - ) || ( - GlobalSetting.redis_config[:replica_host] && - Discourse.redis.connection[:host] == GlobalSetting.redis_config[:replica_host] ) rescue => e if e.is_a?(Redis::CannotConnectError) - true - else Rails.logger.warn "#{e.class} #{e.message}: #{e.backtrace.join("\n")}" - false end + + false end end