Increase redis lock expiry time to 30 seconds

This commit is contained in:
James Allen 2014-05-07 09:48:29 +01:00
parent c2ebaaa338
commit d1434f7646
2 changed files with 3 additions and 3 deletions

View file

@ -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"

View file

@ -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", ->