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

fix: Scheduler does not set the next record to delay stream #204

Merged
merged 3 commits into from
May 25, 2020

Conversation

intpro
Copy link
Contributor

@intpro intpro commented May 23, 2020

Assume we have one deleayed job.

Scheduler on start loads incorrect local nextTimestamp value 6513388584960082.
It isn't divided by 4096 in https://github.com/taskforcesh/bullmq/blob/master/src/classes/queue-scheduler.ts#L51-L58

So for every iteration the following code wouldn't be executed. It does not set the next timestamp for execution in delay stream: https://github.com/taskforcesh/bullmq/blob/master/src/classes/queue-scheduler.ts#L101-L112

I don't know how to write test suite for such case. But this fix helps to alive our frozen cron tasks in production.

BTW for what purpose do you divide & multiply timestamp by 4096? We really spent a lot of time to figure out this mistake.

@intpro
Copy link
Contributor Author

intpro commented May 23, 2020

I don't know what happens with Travis tests. But my changes do not affect on that 2 failing tests.

@manast
Copy link
Contributor

manast commented May 25, 2020

Good catch!.
The reason we divide by 4096 is that that gives us 12 bits (2^12 = 4096) for storing the job id. The value of the combined job id and the timestamp is used as the score in the delay set, this guarantee that at least 4096 jobs in the same timestamp will be processed in the right order (only works for ids generated by bullmq not for custom job ids.

@manast manast merged commit 9562d74 into taskforcesh:master May 25, 2020
manast pushed a commit that referenced this pull request May 25, 2020
…-25)

### Bug Fixes

* **scheduler:** divide next timestamp  by 4096 ([#204](#204)) ([9562d74](9562d74))
@manast
Copy link
Contributor

manast commented May 25, 2020

🎉 This PR is included in version 1.8.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants