Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Use ActiveJob 5.2 retry logic for old jobs #36057
Rails 6 introduces retries per-exception, instead of a global count of retries. Because ActiveJob 5.2 doesn't serialize the execution count per-exception, when ActiveJob 6.0 picks up an "old" job it can't know the exception count in the new format.
This can also be an issue if AJ 6.0 serializes a new job with exception_executions which is later picked up by AJ 5.2, which would clear exception_executions (since it has no knowledge of it).
Previously we handled this by resetting exception_executions, if it wasn't defined on a job, which could result in the worst case retrying the job 2x the times we should.
This commit changes how we handle loading a legacy job: instead of resetting exception_executions, we instead will always use the global executions count.
This way, jobs which only have one retry_on (and didn't have a behaviour change in AJ 6) are backwards-and-forwards-compatible with counts respected exactly.
Jobs with multiple retry_on will revert to the AJ5.2 behaviour if they were ever run under AJ5.2.
kaspth left a comment
Dig the extra test coverage!
I guess the main way to conceptualize this is that if Active Job 5.2 touches a job at any point
@kaspth I think it's the other way around, from 5.2 to 6.0, because in 6.0 we still increment