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

Uniqueness breaks jobs #160

Closed
kholbekj opened this issue Feb 4, 2016 · 3 comments
Closed

Uniqueness breaks jobs #160

kholbekj opened this issue Feb 4, 2016 · 3 comments

Comments

@kholbekj
Copy link

kholbekj commented Feb 4, 2016

After upgrading to sidekiq 4 it appears that adding the unique option breaks job scheduling completely for me.

class RecalculatePostRecommendationsJob
  include Sidekiq::Worker

  sidekiq_options queue: :lowest, unique: :until_executing

  def perform(post_id)
    post = Post.find(post_id)
    Recommendation.recalculate_all_for!(post)
  end
end

My spec:

  it 'is triggered when a post is created', sidekiq: :inline do
    expect_any_instance_of(RecalculatePostRecommendationsJob).to receive(:perform).with(47)
    create :post, id: 47
  end

The spec will pass if i remove the unique option.
Also, in a console I'm not able to add the jobs to an empty queue

(1)> RecalculatePostRecommendationsJob.perform_in(5.minutes, 1)
=> 5374aff8026836612515e291
(2)> Sidekiq::Queue.new('lowest').size
=> 0

If i remove the unique option everything works as it used to.

Sidekiq 4.1.0, sidekiq-unique-jobs 4.0.13

@mhenrixon
Copy link
Owner

Thanks for reporting! I'll try and replicate it locally.

@kholbekj
Copy link
Author

kholbekj commented Feb 8, 2016

Aaaaand we were missing require 'sidekiq_unique_jobs/testing' in spec helper.
So if you can just shoot me, that'd be great.

@kholbekj kholbekj closed this as completed Feb 8, 2016
@mhenrixon
Copy link
Owner

Thank you for for posting the solution @kholbekj.

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