Question

I've implemented long-running tasks in my Rails app using delayed_job along with delayed_job_web. My delayed_job configuration instructs jobs to be attempted once, and for failures to be retained:

config/initializers/delayed_job.rb:

Delayed::Worker.max_attempts = 1
Delayed::Worker.destroy_failed_jobs = false

I tried 2 test jobs that automatically raised errors, in order to see how failures behave. What I get is the following:

enter image description here

My expectation was that Failed jobs would have a count of 2, but that Enqueued / Working / Pending would all be 0. I can't find any documentation on what determines whether a job is Enqueued / Working / Pending, or even what the difference between Working and Pending is (the web interface describes both lists as "contains jobs currently being processed".)

Can anyone provide some clarity?

Was it helpful?

Solution

If you check https://github.com/ejschmitt/delayed_job_web/blob/master/lib/delayed_job_web/application/app.rb , you see the following (starting line 114):

when :working
  'locked_at is not null'
when :failed
  'last_error is not null'
when :pending
  'attempts = 0'
end
  1. Enqueued would be the total number of delayed jobs, i.e. Delayed::Job.count

  2. Working jobs are those that have been locked by the delayed_job process and are currently being worked.

  3. Failed are those that have a last_error

  4. Pending are those jobs that have never been attempted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top