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

Allow one running job but at most one job in the queue #748

Closed
asross opened this issue Dec 9, 2022 · 2 comments
Closed

Allow one running job but at most one job in the queue #748

asross opened this issue Dec 9, 2022 · 2 comments

Comments

@asross
Copy link

asross commented Dec 9, 2022

Is your feature request related to a problem? Please describe.

My problem is similar to the one which inspired until_executing, but a bit different. We have a long-running job that gets triggered by updates from a number of different sources. This job requests data at the beginning of its run and there's a danger that the data can become stale by the time it finishes. Therefore, we need this job to run once after the final trigger. However, once it starts running, we don't want to interrupt it, and we also don't want to run multiple at the same time (since it's big and expensive).

So if we get an initial trigger, we want the job to start running, and then if we get another trigger, we want to enqueue another job to run after the first finishes, but if we get another trigger after that, we want to ignore it (since we can be sure that the enqueued job will have access to all the data it needs by the time it starts running).

Describe the solution you'd like

I'd love something like lock: :max_one_executing_and_one_enqueued, where we have one lock for the queue and one lock for execution. This means if we get a flood of requests, one will start running, one will wait to start until after it finishes, and subsequent requests will be ignored.

@juanmiret-sn
Copy link

Would't this do the job?

sidekiq_options lock: :until_and_while_executing, on_conflict: { client: :replace, server: :reschedule }

@pboling
Copy link
Contributor

pboling commented Feb 26, 2023

@mhenrixon This issue can be closed.

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

No branches or pull requests

4 participants