Преглед изворни кода

release the lock if it took too long to acquire it

Brian Gough пре 9 година
родитељ
комит
bb0dc4b4d5
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      services/document-updater/app/coffee/LockManager.coffee

+ 4 - 1
services/document-updater/app/coffee/LockManager.coffee

@@ -41,7 +41,10 @@ module.exports = LockManager =
 				metrics.inc "doc-not-blocking"
 				metrics.inc "doc-not-blocking"
 				timeTaken = profile.log("got lock").end()
 				timeTaken = profile.log("got lock").end()
 				if timeTaken > MAX_REDIS_REQUEST_LENGTH
 				if timeTaken > MAX_REDIS_REQUEST_LENGTH
-					callback err, false # took too long to get the lock, bail out
+					# took too long, so try to free the lock
+					LockManager.releaseLock doc_id, lockValue, (err, result) ->
+						return callback(err) if err? # error freeing lock
+						callback null, false # tell caller they didn't get the lock
 				else
 				else
 					callback err, true, lockValue
 					callback err, true, lockValue
 			else
 			else