From d1434f764614223fcb03958442882a2604ad64de Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 7 May 2014 09:48:29 +0100 Subject: [PATCH] Increase redis lock expiry time to 30 seconds --- services/document-updater/app/coffee/LockManager.coffee | 4 ++-- .../test/unit/coffee/LockManager/tryLockTests.coffee | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/document-updater/app/coffee/LockManager.coffee b/services/document-updater/app/coffee/LockManager.coffee index 97c06ad721..a43bd84a1b 100644 --- a/services/document-updater/app/coffee/LockManager.coffee +++ b/services/document-updater/app/coffee/LockManager.coffee @@ -10,10 +10,10 @@ logger = require "logger-sharelatex" module.exports = LockManager = LOCK_TEST_INTERVAL: 50 # 50ms between each test of the lock MAX_LOCK_WAIT_TIME: 10000 # 10s maximum time to spend trying to get the lock + REDIS_LOCK_EXPIRY: 30 # seconds. Time until lock auto expires in redis. tryLock : (doc_id, callback = (err, isFree)->)-> - tenSeconds = 10 - rclient.set keys.blockingKey(doc_id: doc_id), "locked", "EX", 10, "NX", (err, gotLock)-> + rclient.set keys.blockingKey(doc_id: doc_id), "locked", "EX", LockManager.REDIS_LOCK_EXPIRY, "NX", (err, gotLock)-> return callback(err) if err? if gotLock == "OK" metrics.inc "doc-not-blocking" diff --git a/services/document-updater/test/unit/coffee/LockManager/tryLockTests.coffee b/services/document-updater/test/unit/coffee/LockManager/tryLockTests.coffee index cff2b9538b..6c2c8972af 100644 --- a/services/document-updater/test/unit/coffee/LockManager/tryLockTests.coffee +++ b/services/document-updater/test/unit/coffee/LockManager/tryLockTests.coffee @@ -21,7 +21,7 @@ describe 'LockManager - trying the lock', -> @LockManager.tryLock @doc_id, @callback it "should set the lock key with an expiry if it is not set", -> - @set.calledWith("Blocking:#{@doc_id}", "locked", "EX", 10, "NX") + @set.calledWith("Blocking:#{@doc_id}", "locked", "EX", 30, "NX") .should.equal true it "should return the callback with true", ->