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

feat(job): provide decrementAttemptsMade option in moveToDelayed #2203

Conversation

roggervalf
Copy link
Collaborator

@roggervalf roggervalf commented Sep 30, 2023

ref #2152

@roggervalf
Copy link
Collaborator Author

roggervalf commented Sep 30, 2023

It's desired to keep the attemptMade up today, we may need to think more about it

@roggervalf roggervalf closed this Sep 30, 2023
@roggervalf roggervalf deleted the feat-move-to-delayed-skip-attempt branch September 30, 2023 16:40
@roggervalf roggervalf restored the feat-move-to-delayed-skip-attempt branch December 2, 2023 01:15
@roggervalf roggervalf reopened this Dec 2, 2023
@roggervalf roggervalf changed the title feat(job): provide skip attempt option in moveToDelayed feat(job): provide decrementAttemptsMade option in moveToDelayed Dec 2, 2023
moveToDelayed(
timestamp: number,
token?: string,
skipAttempt?: boolean,
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having booleans it is much more descriptive to use an options object with a skipAttempt option in it.

@@ -683,6 +685,7 @@ export class Scripts {
jobId,
token,
delay,
opts.decrementAttempt ? '1' : '0',
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this a bit awkward, in the sense that we must decrement to effectively achieve a non-increment of attemptsMade. I think it would be better to not increment instead of increment and then decrement.

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is probably that we increment attemptsMade as soon as the job is moved to active, but maybe we should increment this property when the job is completed or failed.

Copy link
Contributor

Choose a reason for hiding this comment

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

When a job is moved to active we have not "made an attempt" we have "started an attempt", but it is not until the job finishes we should consider the attempt to be made, what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we may not only consider when it completes or fails, also when it's moved to delayed, retried script and movedToWaitingChildren

Copy link
Contributor

Choose a reason for hiding this comment

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

We should think that "attemptsMade" main use is for the error retries, and the backoff function. So actually increasing it when completing the job or failing would work well in this regard. On the other hand, it is also good to know how many times a job has been started, but may for some reason not finished, like it was considered stalled and moved back to wait, or it has been considered rate-limited, and so on.

@roggervalf roggervalf changed the base branch from master to feat/better-handling-of-queue-markers December 9, 2023 14:00
@roggervalf roggervalf changed the base branch from feat/better-handling-of-queue-markers to master December 9, 2023 14:52
@roggervalf roggervalf changed the base branch from master to feat/better-handling-of-queue-markers December 9, 2023 17:15
@roggervalf roggervalf merged commit 0e88e4f into feat/better-handling-of-queue-markers Dec 9, 2023
@roggervalf roggervalf deleted the feat-move-to-delayed-skip-attempt branch December 9, 2023 17:46
);

if (!opts.skipAttempt) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the scenario where skipAttempt is necessary?

github-actions bot pushed a commit that referenced this pull request Dec 21, 2023
# [5.0.0](v4.17.0...v5.0.0) (2023-12-21)

### Bug Fixes

* **connection:** require connection to be passed ([#2335](#2335)) ([1867dd1](1867dd1))
* **job:** revert console warn custom job ids when they represent integers ([#2312](#2312)) ([84015ff](84015ff))
* **python:** unify redis connection args for Queue and Worker ([#2282](#2282)) ([8eee20f](8eee20f))
* **worker:** throw error if connection is missing ([6491a18](6491a18))

### Features

* **job:** provide skipAttempt option when manually moving a job ([#2203](#2203)) ([0e88e4f](0e88e4f))
* **python:** use new queue markers ([b0a13e8](b0a13e8))
* **python:** use new queue markers ([4276eb7](4276eb7))
* **worker:** improved markers handling ([73cf5fc](73cf5fc))
* **worker:** improved markers handling ([0bac0fb](0bac0fb))

### BREAKING CHANGES

* **worker:** Markers use now a dedicated key in redis instead of using a special Job ID.
* **worker:** Markers use now a dedicated key in redis instead of using a special Job ID.
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