From 7d24ce671b89313fd04e88d4480dfdb44760d9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 5 Apr 2017 11:43:29 +0200 Subject: [PATCH] Update queue index while enqueueing jobs to the top of queue --- NEWS.md | 3 +++ batch/job_queue.js | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index c6dbd999..a9f66fcc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,9 @@ ## 1.44.2 Released 2017-mm-dd +Bug fixes: + - Update queue index while enqueueing jobs to the top of queue. + ## 1.44.1 Released 2017-04-04 diff --git a/batch/job_queue.js b/batch/job_queue.js index 2e6135e8..10d848b3 100644 --- a/batch/job_queue.js +++ b/batch/job_queue.js @@ -63,7 +63,17 @@ JobQueue.prototype.dequeue = function (user, callback) { JobQueue.prototype.enqueueFirst = function (user, jobId, callback) { debug('JobQueue.enqueueFirst user=%s, jobId=%s', user, jobId); - this.metadataBackend.redisCmd(QUEUE.DB, 'RPUSH', [ QUEUE.PREFIX + user, jobId ], callback); + this.metadataBackend.redisMultiCmd(QUEUE.DB, [ + [ 'RPUSH', QUEUE.PREFIX + user, jobId ], + [ 'SADD', QUEUE.INDEX, user ] + ], function (err) { + if (err) { + return callback(err); + } + + this.jobPublisher.publish(user); + callback(); + }.bind(this)); };