-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
When not preserving job records, ensure all prior executions are deleted after successful retry #719
When not preserving job records, ensure all prior executions are deleted after successful retry #719
Conversation
@ylansegal thank you for opening up this PR. I think you've discovered a bug 🎉 I need to think about this a bit more. I don't think the fix here is quite right because I think if a a job is retried (which will generate a new execution) this PR will delete that new execution, which isn't desired. Here is where the good_job/app/models/good_job/execution.rb Lines 294 to 306 in e13915e
I'm thinking this logic needs to be unrolled to more clearly separate "This is what happened with the job/execution (e.g. succeeded, retried, discarded/handled, unhandled" and then within that have the logic of "and based on the configuration, this is what should happen with the record". I might push up into your branch unless you want to dig into that more. |
I definitely had not considered retries fully. My thinking was that failed jobs are preserved, which would not trigger the callback. That seems to be an assumption on how I have configured GoodJob in my project.
Feel free to push to that branch! You definitely have more knowledge of the internals. |
…argeted method for destroy
Released in v3.4.8 🎉 Thank you for the fix 🙌🏻 |
@ylansegal sorry, I need to revert this because of an unexpected issue in #728. I will figure out a better implementation and get this behavior re-added. |
Thank you @bensheldon |
When records are configured to be preserved on
on_unhandled_error
, and later retried, the previous executions stay in the database and become "orphaned". I believe they should be deleted on a successful retry. This would bring it inline with the behavior for destroying a failed job (eg. via the UI) which results in previous executions also being deleted.This is my first contribution to this repo. I took a stab at writing a spec that exposes the issue and a fix via a ActiveRecord callback. I am open to suggestions for improvement.
Thank you for making
good_job
available and open source!