-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Preserve only failed jobs #136
Comments
@morgoth I think this is a great feature request and could see it implemented in GoodJob. I looked at how easy it would be to implement outside of GoodJob; GoodJob isn't currently instrumented to make it easy :-( So there are two options:
|
@bensheldon How would you see it implemented? I was thinking about changing config values for Then I guess we would also need to set Do you have some different idea on your mind? |
Sidekiq has an interesting way to manage the failed jobs: "Failed jobs" means the number of times a job has failed, even if, maybe, it eventually ran successfully after several retries. "Dead jobs" is a queue where the jobs that have been retried failed more than N number of times go. Usually, when you have a problem with a job, you catch it in the retries queue because they usually retry during a couple of times, but when Sidekiq gives up, you can find them in "Dead jobs." I think that this is a really useful pattern. So, my point is that, keeping jobs that have ran successfully can be optional, but dead jobs should never be removed. |
@morgoth Yes! That's very close to my initial thoughts. Some suggested adjustments:
@6temes Thanks for sharing how Sidekiq organizes them. That's really helpful. I like the idea of Failed vs Dead. I'm trying to think about the analogous data with GoodJob and it's complicated. A wrinkle of GoodJob is that an ActiveJob job, when retried, will generate a new GoodJob Job in the database. In other words, there is not a 1-to-1 correspondence between an ActiveJob Job and a GoodJob Job. To determine a "Dead" ActiveJob Job would require identifying Errored GoodJob Jobs that don't have a newer matching enqueued job. That's doable, but it might be unsatisfyingly messy. I'm imagining, for example, that a GoodJob::Job, if it is a retried job, could store a reference to the previously errored job that generated it. To give an example of the messiness, currently tracking the error state on retries/discards requires passing global state around: good_job/lib/good_job/railtie.rb Lines 9 to 17 in 5b59acd
I have appetite for using global state to enable these features, but, well, it's complicated. |
Looks like currently there is no configuration option to preserve only failed jobs and delete successfully finished ones, as
preserve_job_records
will preserve all.I think it would be very helpful to have such functionality out of the box (or by config) to be possible to easily investigate failed job errors.
Is this easy to do on my own, with currently available GoodJob API?
The text was updated successfully, but these errors were encountered: