From bb0dc4b4d5a2885529b2c804ece5f1460cf78788 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 12 Jul 2017 10:45:23 +0100 Subject: [PATCH] release the lock if it took too long to acquire it --- services/document-updater/app/coffee/LockManager.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/document-updater/app/coffee/LockManager.coffee b/services/document-updater/app/coffee/LockManager.coffee index cd6df46878..0aa1e3695e 100644 --- a/services/document-updater/app/coffee/LockManager.coffee +++ b/services/document-updater/app/coffee/LockManager.coffee @@ -41,7 +41,10 @@ module.exports = LockManager = metrics.inc "doc-not-blocking" timeTaken = profile.log("got lock").end() 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 callback err, true, lockValue else