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

resque_solo does not play well with scheduled jobs #11

Closed
rhymes opened this issue Nov 15, 2016 · 4 comments
Closed

resque_solo does not play well with scheduled jobs #11

rhymes opened this issue Nov 15, 2016 · 4 comments

Comments

@rhymes
Copy link

rhymes commented Nov 15, 2016

Hi,

I am using https://github.com/wanelo/counter-cache to schedule counting jobs that get enqueued automatically after a few actions. Unfortunately counter-cache is not smart in the sense that it doesn't detect if a job is already in the queue, hence why I started using resque_solo which works perfectly for "immediate" counting jobs, it does not work with schedule ones.

As you can see:

screen shot 2016-11-15 at 11 11 25 am

some of these jobs have the same signature and same timestamp. I'd argue that jobs with the same timestamp and signature should not be in the queue at the same time, correct?

Thank you

@teeparham
Copy link
Member

How is your CounterCacheJob configured?

@rhymes
Copy link
Author

rhymes commented Nov 15, 2016

@teeparham sorry, I forgot to add that:

class CounterCacheJob
  include Resque::Plugins::UniqueJob

  @queue = :counter_cache

  # adapted from https://github.com/wanelo/counter-cache#default_worker_adapter
  def self.perform(base_class, options)
    options.symbolize_keys!
    options[:source_object_class_name] = base_class.constantize
    # options[:counter] is the class name of the counter that called the adapter
    counter_class = options[:counter].constantize
    counter = counter_class.new(nil, options)
    counter.save!
  end
end

@teeparham
Copy link
Member

That looks like your job is configured OK. I suspect that the jobs are scheduled, but they are not enqueued until the scheduler runs. At that time, resque_solo will check the queue and either enqueue the job or not. I don't think there's any issue with this gem. If you want to prevent scheduling duplicate jobs, that's up to whatever you're using to schedule jobs.

@rhymes
Copy link
Author

rhymes commented Nov 15, 2016

@teeparham I'm using https://github.com/resque/resque-scheduler - you're probably right, it makes sense because the scheduler can enqueue the jobs ONLY when they need to be executed

I've also found this five year old thread about it resque/resque-scheduler#113

it seems there's no easy solution :)

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