FIX: Ensure PresenceChannel does not raise error during readonly (#22899)

PresenceChannel configuration is cached using redis. That cache is used, and sometimes repopulated, during normal GET requests. When the primary redis server was readonly, that `redis.set` call would raise an error and cause the entire request to fail. Instead, we should ignore the failure and continue without populating the cache.
This commit is contained in:
David Taylor
2023-08-01 09:34:57 +01:00
committed by GitHub
parent 6286e790b2
commit bb217bbcc8
2 changed files with 10 additions and 1 deletions

View File

@@ -314,7 +314,10 @@ class PresenceChannel
else
raise InvalidConfig.new "Expected PresenceChannel::Config or nil. Got a #{result.class.name}"
end
PresenceChannel.redis.set(redis_key_config, to_cache, ex: CONFIG_CACHE_SECONDS)
DiscourseRedis.ignore_readonly do
PresenceChannel.redis.set(redis_key_config, to_cache, ex: CONFIG_CACHE_SECONDS)
end
raise PresenceChannel::NotFound if result.nil?
result