FIX: Use string for postgres recently readonly DistributedCache (#21040)

Since DistributedCaches don't marshal timestamps
This commit is contained in:
Daniel Waterworth 2023-04-10 13:54:55 -05:00 committed by GitHub
parent fcc73b441d
commit c68497159f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -715,13 +715,10 @@ module Discourse
end
def self.postgres_recently_readonly?
timestamp =
postgres_last_read_only.defer_get_set("timestamp") do
seconds = redis.get(LAST_POSTGRES_READONLY_KEY)
Time.zone.at(seconds.to_i) if seconds
end
seconds =
postgres_last_read_only.defer_get_set("timestamp") { redis.get(LAST_POSTGRES_READONLY_KEY) }
timestamp.present? && timestamp > 15.seconds.ago
seconds ? Time.zone.at(seconds.to_i) > 15.seconds.ago : false
end
def self.recently_readonly?