Describe the bug
A worker with lock: :while_executing and on_conflict: :reschedule is being rescheduled in a loop after completion.
Expected behavior
Usual Sidekiq worker behaviour, i.e. job being removed from queue after execution.
Current behavior
"Reschedule" strategy runs after the worker code is executed scheduling it to be run again 5 seconds after completion.
Worker class
class Job
include Sidekiq::Worker
sidekiq_options lock: :while_executing,
lock_timeout: 5,
on_conflict: :reschedule
def perform
puts 'hello'
sleep 1
puts 'bye'
end
end
Additional context
I believe the problem is here - whether the strategy will be called or not relies on the result of the callback_safely which by default returns nil. If I add a callback to the worker class like
def after_unlock
true
end
everything works as expected.
Describe the bug
A worker with
lock: :while_executingandon_conflict: :rescheduleis being rescheduled in a loop after completion.Expected behavior
Usual Sidekiq worker behaviour, i.e. job being removed from queue after execution.
Current behavior
"Reschedule" strategy runs after the worker code is executed scheduling it to be run again 5 seconds after completion.
Worker class
Additional context
I believe the problem is here - whether the strategy will be called or not relies on the result of the
callback_safelywhich by default returns nil. If I add a callback to the worker class likeeverything works as expected.