-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Unable to discard failed jobs which crashed with ActiveJob::DeserializationError
#770
Comments
@nickcampbell18 thank you for the bug report. This is a really interesting/exciting find and I appreciate you tracing it down through GoodJob! 🙌🏻 I think that GoodJob should cover this situation. GoodJob's Dashboard UI tries to perform the various actions through ActiveJob (or simulate it as closely as possible). In this case that the ActiveJob object is invalid (or at least un-deserealizable), I think GoodJob should recognize/rescue from that situation and be able to successfully perform the discard action. From quickly looking into the code, it seems like the ActiveJob object is only deserialized to trigger instrumentation within good_job/app/models/good_job/job.rb Lines 222 to 223 in b84ef5a
And even looking at the construction of the ActiveJob object, it seems like it's maybe doing too much all the time by always deserializing arguments: good_job/app/models/good_job/execution.rb Lines 319 to 323 in b84ef5a
The only two places that GoodJob seems to try to deserialize an ActiveJob object are for I'm thinking that maybe the def active_job(safe_deserialize: false)
ActiveJob::Base.deserialize(active_job_data).tap do |aj|
aj.send(:deserialize_arguments_if_needed)
rescue ActiveJob::DeserializationError
raise unless safe_deserialize
end
end and Would you want to try making and testing a change like that (I'm also open to other ideas too)? |
Love it. Will send a patch! |
Hi team, not 100% sure whether this issue is caused by Rails or GoodJob, but here goes!
Steps to reproduce
ActiveJob::DeserializationError
when a GoodJob executor picks it upExpected behaviour
User can discard the job, even though the arguments cannot deserialize
Actual behaviour
The GoodJob web UI crashes with an exception, user gets a HTTP 500 error page. It looks like calling
execution.active_job
is what triggers Rails to attempt to deserialize the arguments, and crash. Here's the relevant parts of the backtrace:I'm aware this is possibly a niche issue. Rails generates the commented-out code
discard_on ActiveJob::DeserializationError
inApplicationRecord
, to encourage you to consider this by default, but in my application we had never enabled it globally and I would guess others also haven't, so I think there's good cause for fixing it.I could see an argument for proposing a fix to Rails itself, maybe for a way to load the job without deserializing the arguments (e.g. for instrumentation purposes, as we use it here). However, from reading the code, it looks like we currently generate a synthetic error (
DiscardJobError
) and then mark that as the error of the job. Maybe we could catch the deserialization error specifically, and mark it as the ancestor of the discard error so the history is preserved? I don't know whether there are other core exceptions expected simply by loading the job/arguments (I haven't seen others before) so it feels a little weird to have this tight dependency on a specific exception... but otherwise I can't think of an elegant fix to this issue.I'd be happy to submit a patch if there's a good way to go here 😄
Thank you maintainers! Love this gem ❤️
The text was updated successfully, but these errors were encountered: