Skip to content

after_unlock isn't called unless it's a class method #526

@wasabigeek

Description

@wasabigeek

Describe the bug
Accord the docs, we can declare after_unlock as an instance method. In our case though, after_unlock doesn't seem to get called unless it's declared as a class method. Is there something we missed?

Worker class

class ExampleWorker
  include Sidekiq::Worker
  sidekiq_options queue: :low,
                  lock: :until_executed,
                  log_duplicate_payload: true,
                  retry: 3,
                  dead: false

  def perform(lead_id, crm_integration_id)
     ...
  end

  def after_unlock
    # not called
    Sidekiq.logger.info(message: "#{self.class.name} after_unlock", ...)
     ...
  end

  def self.after_unlock
    # called
    Sidekiq.logger.info(message: "#{self.class.name} after_unlock", ...)
    ...
  end
end

Additional context
Ruby Version: ruby-2.5.8
The sidekiq gems we have in Gemfile.lock:

    sidekiq (6.0.7)
      connection_pool (>= 2.2.2)
      rack (~> 2.0)
      rack-protection (>= 2.0.0)
      redis (>= 4.1.0)
    sidekiq-status (1.1.4)
      chronic_duration
      sidekiq (>= 3.0)
    sidekiq-unique-jobs (6.0.21)
      concurrent-ruby (~> 1.0, >= 1.0.5)
      sidekiq (>= 4.0, < 7.0)
      thor (~> 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions