From fd8bf5d2cbc78f22596e7f1bd69df92f7c51ed38 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 20 Sep 2018 15:18:35 +1000 Subject: [PATCH] FIX: correct readonly timeout So it only applies in readonly mode --- lib/distributed_mutex.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/distributed_mutex.rb b/lib/distributed_mutex.rb index 76def3e785..d47f059d0f 100644 --- a/lib/distributed_mutex.rb +++ b/lib/distributed_mutex.rb @@ -22,10 +22,12 @@ class DistributedMutex while !try_to_get_lock sleep 0.001 - attempts += 1 # in readonly we will never be able to get a lock - if @using_global_redis && attempts > CHECK_READONLY_ATTEMPT - raise Discourse::ReadOnly + if @using_global_redis && Discourse.recently_readonly? + attempts += 1 + if attempts > CHECK_READONLY_ATTEMPT + raise Discourse::ReadOnly + end end end