-
-
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
while_executing
with on_conflict: :reschedule
reschedules job when unlock fails
#770
Comments
Is that only for blocks? For a rescue ensure scenario in a method, the ensure part would only return something with an explicit return. Are blocks different? |
If the ensure part would indeed return something it would say "pokus" not "hokus". |
In our case I believe this happened:
If unlock succeeds everything works as you mentioned:
|
So maybe a different approach to solve this would be def execute(&block)
with_logging_context do
executed = locksmith.execute do
yield
ensure
callback_safely if locksmith.unlock
end
unless executed
reflect(:execution_failed, item)
call_strategy(origin: :server, &block)
end
end
end ? To be honest I wasn't aware that the result of the |
Ah now I see your problem doh 🙄 |
Thank you! |
Hi there! 👋
I am not 100% sure if this really is a bug or if I am not understanding the use case.
Describe the bug
sidekiq-unique-jobs/lib/sidekiq_unique_jobs/lock/while_executing.rb
Lines 41 to 52 in 98a3e8e
Because
executed
captures the return value of thelocksmith.execute
block it will be falsy when the unlock operation failed (and whencallback_safely
returns something fasly?).We noticed the behaviour on v7 with a sidekiq version that changed the redis key that hold the busy workers (#756), in our case this lead to a job being run over and over because
unlock
failed (the reaper deleted the lock of the running job).Expected behavior
The server server strategy should only be called when the job lock could not be acquired, not when the unlock failed (successfully 😉 )
Maybe something like this?
Worker class
The text was updated successfully, but these errors were encountered: