Skip to content
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

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

Closed
wasabigeek opened this issue Jul 2, 2020 · 1 comment
Closed

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

wasabigeek opened this issue Jul 2, 2020 · 1 comment

Comments

@wasabigeek
Copy link

wasabigeek commented Jul 2, 2020

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)
@mhenrixon
Copy link
Owner

#571 v7.0.1 is highly recommended. I can't remember if I fixed this for v6, but for v7, I definitely try both the class and instance method of the after_unlock method, so you don't have to worry about which one you define it as.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants