BUG: Repeat Jobs stop processing
Created by: mbernardini
We're noticing an issue that when using repeat jobs, the jobs eventually stop processing with no indication of an error. The reason that the jobs stop is that the next job does not get added to the queue. I ran NODE_DEBUG=bull and added some additional debug statements, so I was able to figure out that nextRepeatableJob
function is being called but this check is causing the next job to not get added because now
is a few milliseconds before millis
(the time the job is supposed to get executed).
This script reproduces the issue:
const Queue = require('bull');
const prefix = 'test';
const redis = {host: 'localhost', port: 6379};
const cronQueue = new Queue('cronQueue', {redis, prefix});
cronQueue.process('cron', () => {
console.log(`[${(new Date()).toISOString()}] Job Processing...`);
});
cronQueue.add('cron', {}, {repeat:{cron:'*/10 * * * *'}, jobId: 'cronJob', removeOnComplete: true});
Output:
[2017-10-20T17:20:00.012Z] Job Processing...
[2017-10-20T17:29:59.987Z] Job Processing...
// Theres no more out at this point because the second job executed prior to the scheduled time
For reference: Bull version: 3.3.2 Node Version: 6.9.0 Redis Version: 2.8.19 and 3.2.4 I've seen this issue both running Redis and Node on a single machine as well as in our cloud environment (clustered Redis and multiple Node instances)