Skip to content

Sidekiq::Worker.set not working with sidekiq-unique-jobs #242

@Omicron7

Description

@Omicron7

I'm running into an issue where using the Sidekiq::Worker.set method (see here) to set worker options seems to prevent sidekiq-unique-jobs from enforcing uniqueness.

Here's an example.

class HardWorker
  include Sidekiq::Worker
  sidekiq_options retry: false, unique: :until_and_while_executing
  
  def perform(name, count); end
end

Calling HardWorker.perform_async('foo', 1) multiple times is successful and only 1 job is enqueued.

Sometimes though, I want this worker on a different queue, so we call HardWorker.set(queue: :critical).perform_async('foo', 1). Calling this multiple times adds and additional job to the queue for each call. Looking at HardWorker.jobs I see multiple identical jobs, same args, same unique_digest. I believe uniqueness should still be enforced in this case.

The issue occurs with sidekiq 5.x and any version of sidekiq-unique-jobs (tested 4.0.18 and 5.0.10), does not occur when using sidekiq 4.x.

I can create a simple project with a failing spec if it helps. If you have any questions or need more clarifications, let me know.

Thanks.

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