runs unique jobs multiple times
vollnhals opened this issue · comments
Hi!
I have a simple job using sidekiq and the unique jobs middleware.
class MiniMapWriterJob
include Sidekiq::Worker
# this job should only run once every minute per board
sidekiq_options({
unique: true,
queue: :minimaps,
})
def perform(board_id)
...
end
If i run this job in the rails console with:
100.times do MiniMapWriterJob.perform_async(28) end
then the job is run about 2-4 times. I verify this by watching the debug output in the terminal where i run sidekiq.
I have also tried the sidekiq-unique-jobs gem (https://github.com/form26/sidekiq-unique-jobs) and it works as advertised.
The only major difference seem to be the generation of the payload hash.
Hey @vollnhals, thanks for report.
Sidekiq processes jobs very fast, so your unique job performs before your console run ends, and this repeats multiple times.
For example, put sleep(1) inside perform and you'll see that uniqueness works fine.