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: guarantee every repeatable jobs are slotted #2966

Merged
merged 5 commits into from
Dec 13, 2024

Conversation

manast
Copy link
Contributor

@manast manast commented Dec 12, 2024

This PR adds a guarantee for repeatable jobs based on the "every" option so that only one delayed job per job scheduler can ever be produced by making sure the next iteration is "slotted". By "slotted" we mean that we only allow the repeatable jobs for a given every setting to be placed in evenly slots in the time space. So for example, if we have an every setting of 5000 (5 seconds), then the repetition will be slotted in time 0, 5, 10, 15, 20, 25, and so on. However we also compute an offset so that we can start the iterations at the same point in time the job scheduler is added to the queue. So for instance, if we add the job scheduler at second 10:23:03 (second 3), the iterations will be slotted at 3, 8, 13, 18, and so on.

Another improvement in this PR affects retried repeatable jobs. A repeatable job that has produced the next repeatable job iteration will be marked as such and will not create new iterations independently on how many times this job is retried.

Copy link
Collaborator

@roggervalf roggervalf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

{ data: { foo: 'bar' } },
);

//this.clock.tick(1000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line can be removed

@manast manast merged commit af75315 into master Dec 13, 2024
12 checks passed
@manast manast deleted the fix/guarantee-every-repeatable-jobs-slotted branch December 13, 2024 14:17
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

Successfully merging this pull request may close these issues.

2 participants