FIX: Switch recently readonly mdoe cache to a `DistributedCache`.

FIX: Switch recently readonly mdoe cache to a `DistributedCache`.

A per process cache is hard to reason about. During PostgreSQL
failovers. The site may bounce in and out of readonly mode depending on
which server and process that a request hits.

diff --git a/lib/discourse.rb b/lib/discourse.rb
index c78402b..9ea8ef9 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -354,7 +354,7 @@ module Discourse
   end
 
   def self.last_read_only
-    @last_read_only ||= {}
+    @last_read_only ||= DistributedCache.new('last_read_only', namespace: false)
   end
 
   def self.recently_readonly?

GitHub
sha: e75ad37a

2 Likes