Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeatable jobs 'every': wrong behavior #272

Closed
xrip opened this issue Sep 14, 2020 · 1 comment
Closed

Repeatable jobs 'every': wrong behavior #272

xrip opened this issue Sep 14, 2020 · 1 comment

Comments

@xrip
Copy link

xrip commented Sep 14, 2020

When I add a repeatable job with 'every' parameter I expect it runs every X seconds after the job created, but it's run every X seconds since the day started.

Simple test case:

import { Queue, QueueScheduler, Worker } from 'bullmq';

const queueScheduler = new QueueScheduler('Paint1');
const queue = new Queue('Paint1');

console.log(new Date, '- Adding job');

queue.add('cars', { color: 'blue' }, {
    jobId: "every_20_seconds",
    repeat: {
      every: 20 * 1000, 
      limit: 5,
    }
  });

const worker = new Worker('Paint1', async job => {
    console.log(new Date, '- Running job');
});

Actual results:

2020-09-14T16:51:47.555Z - Adding job
2020-09-14T16:52:00.055Z - Running job
2020-09-14T16:52:20.100Z - Running job

Excepted results:

2020-09-14T16:51:47.555Z - Adding job
2020-09-14T16:52:07.055Z - Running job
2020-09-14T16:52:27.100Z - Running job
@manast
Copy link
Contributor

manast commented Sep 14, 2020

works as designed. This is a distributed queue and we need to execute the jobs in known time points, doing it as you expect will not guarantee unique repetitions when you have several workers processing the queue. More background here: OptimalBits/bull#1239

@manast manast closed this as completed Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants