-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Queue up conflicted jobs and release later #664
Comments
Thx for writing this out, my coworkers and me currently share a similar problem. Due to extensive locking on some objects we want to avoid parallel execution of Jobs that deal with the same object. Example: I'm also wondering if the gem is even intended to be used for this. currently it seems the uniqueness is enforced when the jobs are scheduled. @mhenrixon Do you want such functionality in your gem or do you maybe know about a library that fulfills these requirements? |
You hit on an in-between feature here. I agree that the replace and raise resolutions need to be more sophisticated to cover your scenario, but there are alternatives. Correct me if I misunderstood something:
If you guys are running on Sidekiq 7 you are in luck! What you want to do is have a specific queue with only one worker. Sidekiq 7 makes this ridiculously simple with capsules and 1 thread. If you, on the other hand, need uniqueness, you need to combine the two, or we need to add this feature. |
Hi there! I'm also having a similar use case where I need to ensure that the execution of certain jobs (which I can control with That is: if If I'm understanding @piloos's solution correctly, that'd be achieved with his solution. However I do have some questions:
I'm thinking on doing something similar. I was thinking maybe I can leverage sidekiq and send jobs to a queue with no worker instead of needing to create a custom data structure, but basically the same thing I guess. This might work better for @Joerg-Seitz, as jobs would be visible in sidekiqs view.
Regarding this, keep in mind that if you go this route you lose the ability to scale your sidekiq worker horizontally: sidekiq/sidekiq#6148
|
In our case we have a third party service which we cannot use in parallel. Hence, all our jobs using this 3rd party service should be unique while executing. However, each of these jobs has value and must be executed at some point.
In order to accomplish this we implemented two things:
after_unlock
callback to push the queued up jobs to Sidekiq again. We made a small change on the gem to pass theitem
in theafter_unlock
method.Since our use case seems quite universal, I was wondering if we are over-engineering things here? Are we overlooking built-in mechanisms to accomplish this use case? (Note that I am not a fan of raise/retry in Sidekiq because this is dependent on the retry mechanism and timing of Sidekiq, and neither from
reschedule
method since this is imprecise).Our example code:
The text was updated successfully, but these errors were encountered: