mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
put a 5 second timeout in getting redis lock
This commit is contained in:
parent
ffea31290c
commit
54c0fc1180
1 changed files with 7 additions and 2 deletions
|
@ -14,6 +14,8 @@ PID = process.pid
|
|||
RND = crypto.randomBytes(4).toString('hex')
|
||||
COUNT = 0
|
||||
|
||||
MAX_REDIS_REQUEST_LENGTH = 5000 # 5 seconds
|
||||
|
||||
module.exports = LockManager =
|
||||
LOCK_TEST_INTERVAL: 50 # 50ms between each test of the lock
|
||||
MAX_TEST_INTERVAL: 1000 # back off to 1s between each test of the lock
|
||||
|
@ -37,8 +39,11 @@ module.exports = LockManager =
|
|||
return callback(err) if err?
|
||||
if gotLock == "OK"
|
||||
metrics.inc "doc-not-blocking"
|
||||
profile.log("got lock").end()
|
||||
callback err, true, lockValue
|
||||
timeTaken = profile.log("got lock").end()
|
||||
if timeTaken > MAX_REDIS_REQUEST_LENGTH
|
||||
callback err, false # took too long to get the lock, bail out
|
||||
else
|
||||
callback err, true, lockValue
|
||||
else
|
||||
metrics.inc "doc-blocking"
|
||||
profile.log("doc is locked").end()
|
||||
|
|
Loading…
Reference in a new issue