From cbb4ea1ea8f4f49e3c9f078996efe9bfe28d58e6 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 11 Jun 2020 11:41:06 +0800 Subject: [PATCH] DEV: Don't blow up request redis can't be reached during failover. --- config/initializers/002-rails_failover.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rb index 54692b7f822..a48b3dda215 100644 --- a/config/initializers/002-rails_failover.rb +++ b/config/initializers/002-rails_failover.rb @@ -65,9 +65,14 @@ if ENV["ACTIVE_RECORD_RAILS_FAILOVER"] end RailsFailover::ActiveRecord.register_force_reading_role_callback do - Discourse.redis.exists( - Discourse::PG_READONLY_MODE_KEY, - Discourse::PG_FORCE_READONLY_MODE_KEY - ) + begin + Discourse.redis.exists?( + Discourse::PG_READONLY_MODE_KEY, + Discourse::PG_FORCE_READONLY_MODE_KEY + ) + rescue => e + Discourse.warn_exception(e) + false + end end end