DEV: Don't blow up request redis can't be reached during failover.

This commit is contained in:
Guo Xiang Tan 2020-06-11 11:41:06 +08:00
parent 531eca985e
commit cbb4ea1ea8
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
1 changed files with 9 additions and 4 deletions

View File

@ -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