Skip to content

A worker with "While Executing" lock and "Reschedule" strategy is rescheduled forever #457

@bunyan

Description

@bunyan

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.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions