Edge case: the handle_failure received a modified version of the job args
jipiboily opened this issue · 0 comments
Here is the edge case.
Let's say you have a job failing and you are trying to enqueue it again in a "failed_job" queue or something similar.
What if that job is changing the value of an argument during it's processing, well, the handle_failure will receive a modified version of the job args.
Example:
class MyJob
def self.perform id, ids
ids.map! { |id| id * 2 }
1 / 0
end
end
Now, you won't have the same values...but the ids * 2.
Obviously, this example is shitty because no one would do that, but there could be better reasons, like mapping ids to instances of classes. It doesn't sound like the best idea, but right now, the queue classic worker is crashing, which is really not cool!
Code of the process method is here: https://github.com/ryandotsmith/queue_classic/blob/master/lib/queue_classic/worker.rb#L111
What we could do is add as a first line that looks like this: original_job = job.dup
and use that original_job
when calling the handle_failure method.
I did not try it, I just thought about this now after debugging a similar issue.
How does that sound?