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

SidekiqUniqueJobs::UniqueArgs#create_digest is getting called twice #391

Closed
tacticiankerala opened this issue May 9, 2019 · 4 comments
Closed

Comments

@tacticiankerala
Copy link

tacticiankerala commented May 9, 2019

Describe the bug

I have patched SidekiqUniqueJobs::UniqueArgs#create_digest in my project to support different tenants that I have. But, noticed that this method is getting called twice and the interesting bit is it is getting called the second time even when unique_digest is there in the job.

ps: Sidekiq worker we have does not take any args hence was unable to use unique_args option. Also not wanted to patch it & modify all workers to calculate unique args based on tenant.

Expected behavior

I think this method should not get called when the job already has unique_digest value

Current behavior

It is getting called more than once even when the job already contains a unique_digest and the second time Apartment::Tenant.current is incorrect.

Worker class

module SidekiqUniqueJobs
  class UniqueArgs
    def create_digest_with_apartment
      "#{create_digest_without_apartment}_#{Apartment::Tenant.current}"
    end

    alias_method :create_digest_without_apartment, :create_digest
    alias_method :create_digest, :create_digest_with_apartment
  end
end


class MyWorker
  include Sidekiq::Worker
  sidekiq_options unique: :until_executing, log_duplicate_payload: true

  def perform
   # do something in Redis or Elasticsearch
  end
end

Additional context
Not sure if this is a use case that would happen very often. So, I don't think this is a super critical issue. Though, I would like to know why this method is getting called the second time though

@mhenrixon
Copy link
Owner

I would really love to get to the bottom of this one. I am just right in the middle of finalizing the next version.

Since it seems like sort of an edge case I’ll leave it open until then. I’d be interested in digging into how apartment works at some point.

Sent with GitHawk

@mhenrixon
Copy link
Owner

You are right. I know what to do about this now. Thank you for reporting

@tacticiankerala
Copy link
Author

This is not a blocker by any means. But, a nice to have to be fixed. Let me know if you need anything.

@mhenrixon
Copy link
Owner

I believe this was fixed for v7.0.1; see #571 for how to upgrade.

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