mhenrixon/sidekiq-unique-jobs

Unique jobs only executed once when used with sidekiq-global_id

moiristo opened this issue · 2 comments

Hi,

We are using your gem in combination with sidekiq-global_id. Recently, we noticed that jobs with uniqueness constraints were only executed once. It turns out that the root cause for this was that the unique key for the job wasn't removed from the unique jobs hash.

This isn't necessarily a bug. The solution was to change the order of the client/server middleware chain entries to ensure the the digest is always the same:

Sidekiq.client_middleware do |chain|
  chain.add Sidekiq::GlobalId::ClientMiddleware
  chain.add SidekiqUniqueJobs::Client::Middleware
end

Sidekiq.server_middleware do |chain|
  chain.add SidekiqUniqueJobs::Server::Middleware
  chain.add Sidekiq::GlobalId::ServerMiddleware
end

However, it might be a good idea to raise or log an error when a given digest cannot be found in the unique jobs hash. It took me quite some time now to find out why some jobs weren't executing.

Thanks for reporting, I will have a look at this at some point!

Added to readme! Thank you for reporting