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)); };