mattyr / sidecloq

Recurring / Periodic / Scheduled / Cron job extension for Sidekiq
MIT License
88 stars 12 forks source link

Dup the job spec when enqueueing a job #16

Closed holstvoogd closed 7 years ago

holstvoogd commented 7 years ago

Sidekiq::Client adds the JID it generates to the spec, since the spec is kept in memory by the scheduler, the next time the job is enqueued the spec includes this JID and Sidekiq will use that instead of generating a new one.

This can result in multiple jobs with the same id either enqueued or active. This breaks the locking mechanism of sidekiq-unique-jobs and might have some other unwanted effects.

mattyr commented 7 years ago

cool, looks like a good catch. any chance we can get a test that demonstrates the issue as you describe it? The test you have already is a good one (confirming the equality of the original job spec), but doesn't confirm the JID isn't re-used (or even just maintained in memory from being the same object). thanks!

holstvoogd commented 7 years ago

I've added a test on the scheduler that covers the behaviour a bit better!

mattyr commented 7 years ago

perfect, thanks!