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

Dynamically change delay of the job #543

Closed
wenq1 opened this issue May 11, 2021 · 3 comments
Closed

Dynamically change delay of the job #543

wenq1 opened this issue May 11, 2021 · 3 comments

Comments

@wenq1
Copy link

wenq1 commented May 11, 2021

Is it possible to advance the delay of the job while the job is in the delayed state? As far as I can see it involves resetting the delay and change the zscore of the job. Anything else needs to be done?

At the moment in such case I keep track of the the delay using a custom variable and promote the job instead. In the job I compare the current time with the custom and decide wither to proceed with the job or retry with the new delay. Although working, it seems a bit awkward. Is there a builtin way of doing that?

@manast
Copy link
Contributor

manast commented May 11, 2021

There is no built in way to do it, but as you mentioned is quite straightforward to implement. It could be a lua script that just updates the delay and zscore and sends an event to the delay stream (so that BullMQ knows when to pick it up), and some small bookkeeping to check that the job actually is delayed (to eliminate a possible race condition where the job has already started processing when we try to change the delay time). You can find how delay jobs are added in addJob-8.lua. .

@roggervalf
Copy link
Collaborator

@wenq1 could you please try the last version, it should have the changeDelay method, so this issue could be deleted and #545 as well.

@manast manast closed this as completed Jul 15, 2021
@hoangbn
Copy link

hoangbn commented Oct 1, 2021

This feature does not work for me. Opened a new issue for it: #787

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

No branches or pull requests

4 participants