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(worker): better handling of concurrency when fetching jobs #2242

Merged
merged 18 commits into from
Nov 18, 2023

Conversation

manast
Copy link
Contributor

@manast manast commented Oct 23, 2023

Handles this issue: #2157

src/classes/child-processor.ts Outdated Show resolved Hide resolved
src/classes/worker.ts Outdated Show resolved Hide resolved

// Remove marker from active list.
await client.lrem(this.keys.active, 1, jobId);
if (this.blockUntil > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

but could it be the case that when doing this logic, one delayed job with a lower delay value was added, so if we break here, blockUntil will have a higher value than expected, on the other hand if we continue, we will call moveToActive and get the most updated value if this case happens

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, if a delayed job with lower delay was added, then when calling BRPOPLPUSH we will move the new marker right? and update the timeout accordingly. We must block sometimes, otherwise we will enter in an endless loop calling moveToActive.

src/classes/worker.ts Show resolved Hide resolved
@manast manast merged commit d2e2035 into master Nov 18, 2023
11 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 18, 2023
# [4.14.0](v4.13.3...v4.14.0) (2023-11-18)

### Features

* **worker:** better handling of concurrency when fetching jobs ([#2242](#2242)) ([d2e2035](d2e2035))
@roggervalf roggervalf deleted the feat/better-worker-concurrency branch November 18, 2023 15:03
@urossmolnik urossmolnik mentioned this pull request Nov 22, 2023
1 task
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.

3 participants