Jackson Cunningham
Jackson Cunningham

Reputation: 5073

Rails, Heroku, and Resque: Workers stuck in infinite "working" state

I have a background job that can take up to 5 minutes. I just checked my Resque queue and I see there are "75 workers working" despite those workers having started their jobs days ago.

What does this mean? Was the job completed? Why is it stuck like this and how do I handle this situation?

Here's my job:

class CalculateRelevantEventRankingsForUser

   @queue = :calculate_relevant_event_rankings_for_user

  def self.perform(user_id, newly_voted_event_id)
    begin
      user = User.find(user_id)
      events_to_rerank = user.events_that_share_keywords(newly_voted_event_id)
      events_to_rerank.each do |e|
        e.rank(user_id)
      end
    rescue Resque::TermException
      Resque.enqueue(self, user_id, newly_voted_event_id)
    end
  end

end

And procfile:

resque: env TERM_CHILD=1 bundle exec rake resque:workers QUEUE='*' COUNT='1'

enter image description here

Upvotes: 2

Views: 478

Answers (1)

toddmetheny
toddmetheny

Reputation: 4453

Could be any number of reasons. Your redis provider could have crashed and orphaned the instances. You could've run out of memory on redis. I know that you did have your application designed to queue tons of jobs at one point.

It's possible the UI is stuck because those job ids got orphaned in redis for one reason or another.

Try running redis-cli monitor and checking out the output.

If you just want to clear the stuck jobs: Resque.workers.each {|w| w.unregister_worker}

Reiterating my previously mentioned preference for sidekiq. Based on some of your previous Qs this may no longer be an issue. I know you were potentially making some design changes. Gl.

Upvotes: 4

Related Questions