From c68497159ff2eb423d75878f1900668c9f4f1d1b Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Mon, 10 Apr 2023 13:54:55 -0500 Subject: [PATCH] FIX: Use string for postgres recently readonly DistributedCache (#21040) Since DistributedCaches don't marshal timestamps --- lib/discourse.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/discourse.rb b/lib/discourse.rb index 2256998421d..1c7b1a31abe 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -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?