A platform for community discussion. Free, open, simple.
FIX: properly count DistributedMutex locking attempts
Michael Brown618fb5b34dae
diff --git a/lib/distributed_mutex.rb b/lib/distributed_mutex.rbindex bc29d149512..b456244a6d7 100644--- a/lib/distributed_mutex.rb+++ b/lib/distributed_mutex.rb@@ -88,14 +88,11 @@ class DistributedMutex# Exponential backoff, max duration 1sinterval = attempts < 10 ? (0.001 * 2**attempts) : 1sleep interval+ attempts += 1# in readonly we will never be able to get a lock- if @using_global_redis && Discourse.recently_readonly?- attempts += 1-- if attempts > CHECK_READONLY_ATTEMPTS- raise Discourse::ReadOnly- end+ if @using_global_redis && Discourse.recently_readonly? && attempts > CHECK_READONLY_ATTEMPTS+ raise Discourse::ReadOnlyendendend