Join GitHub today
Keep executions for each specific exception #34352
ActiveJob used the global executions counter to control the number of times a job should be retried. The problem with this approach was that in case a job raised different exceptions during its executions they weren't retried the number of times defined by their
Having the following job:
class BuggyJob < ActiveJob::Base retry_on CustomException, OtherException, attempts: 3 end
If the job raised
With this patch each exception has its specific counter so that the first two executions that raise
If the exceptions that are being raised are different subclasses of the exception listed in
EDIT: From #34337 (comment) there should be one counter per declaration so I think
class CustomError < StandardError; end class CustomerError1 < CustomerError; end class CustomerError2 < CustomerError; end rescue_from CustomError, attempts: 2 # then in job raise CustomerError1 #=> should retry # and on the retry raise CustomerError2 #=> we should not retry any more.
When there are multiple calls to retry on they should defiantly have seperate counters - but if multiple exceptions are listed maybe they should all go to the same counter.
retry_on CustomException, OtherException, attempts: 3
could use a single counter but
retry_on CustomException, attempts: 3 retry_on OtherException, attempts: 3
could use seperate counters.
not easy to be distinguished, is it using same or separate counters if we haven't read the docs
@lsylvester thanks for your comment and suggestions. As @saiqulhaq points out, I couldn't find in the current documentation any clue that subclasses of the exception listed in
Thanks in advance!
At a cursory look, this is
Will also need a solid change log entry. This is a kind of breaking change (though one I’m perfectly comfortable with for 6.0 without deprecation or whatever).
Thanks for your work on this!