DEV: Redis failover should only clear redis recently readonly.

This commit is contained in:
Guo Xiang Tan 2020-06-09 16:36:04 +08:00
parent 716629dc0a
commit a1c13eb3c6
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
2 changed files with 11 additions and 2 deletions

View File

@ -10,7 +10,7 @@ if ENV["REDIS_RAILS_FAILOVER"]
end
RailsFailover::Redis.on_fallback do
Discourse.clear_readonly!
Discourse.clear_redis_readonly!
Discourse.request_refresh!
MessageBus.keepalive_interval = message_bus_keepalive_interval
end

View File

@ -518,12 +518,21 @@ module Discourse
postgres_last_read_only[Discourse.redis.namespace] = Time.zone.now
end
def self.clear_postgres_readonly!
postgres_last_read_only[Discourse.redis.namespace] = nil
end
def self.received_redis_readonly!
redis_last_read_only[Discourse.redis.namespace] = Time.zone.now
end
def self.clear_redis_readonly!
redis_last_read_only[Discourse.redis.namespace] = nil
end
def self.clear_readonly!
postgres_last_read_only[Discourse.redis.namespace] = redis_last_read_only[Discourse.redis.namespace] = nil
clear_redis_readonly!
clear_postgres_readonly!
Site.clear_anon_cache!
true
end