bull
bull copied to clipboard
Repeatable job's delay option doesn't work. Is it a bug or I didn't have correct config?
Description
I'm using bull to do repeatable jobs, and if not receiving success message from client within 1 min then this job should be executed again. This logic works, but all repeatable jobs have more delays (around 50 seconds) although I specified the delay option for every job, i.e. delay: 2.
The job delay will be 0 if run it as non-repeatable, even if the delay option was given 10.
I noticed "Note that for accurate delays, both server and clients should have their clocks synchronized." in the bull document. But don't really understand which server and client they are. I'm testing on a Mac OS High Sierra 10.13.3. The client and server are both local machine. The only difference is that Redis sits in another machine in the same network. Redis server has almost the same time as Mac.
Also tried to config timezone as CST where I'm locating for repeatable jobs. My Mac and redis server are in the same timezone. But it didn't make any difference.
Test code to reproduce
Here is code:
deliveryQueue.add('newDelivery', {name: 'lala'}, {repeat: {cron: '*/1 * * *'}, tz: 'CST', delay: 10})
Bull version: 3.3.10
Node version: 8.9.4
Thanks a lot in advance if anyone give hints.
Actually, repeatable jobs use internally the "delay" option in order to schedule when to be processed. Therefore you cannot mix the delay option and the repeat option, I will raise an error to make this behaviour more clear.
Too busy to come back for updates.... Many thanks to @manast for your clarification. Just wonder if it is possible to let repeatable jobs accept delay option from configuration? Maybe it takes more time to implement this feature. Anyway I know the right usage of delay option now, so happy working with bull.
it would be nice to introduce an initial stagger/offset, for the case where you have many jobs being enqueued at the same time with repeatable schedules, and perhaps they are all set to the same interval, but you want them evenly spread over that interval, so you could then specify a stagger: Math.random()*interval
to act as a delay that will offset when jobs of similar intervals get started, so they don't all start at the same time every time.