aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/exceptions.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use ActiveJob 5.2 retry logic for old jobsJohn Hawthorn2019-04-221-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use individual execution counters when calculating retry delayPatrik Bóna2019-04-121-2/+2
| | | | | | Individual execution counters were introduced in #34352. However `#determine_delay` which is used to calculate retry delay still uses the global counter. This commit fixes it.
* Ensure 0 is always the default for the individual exception counters in ↵Rosa Gutierrez2019-01-081-2/+2
| | | | | | | | | | | ActiveJob Some adapters like Resque that use Redis, convert the Ruby hash with a default value, Hash.new(0), into a regular hash without a default value after serializing, storing and deserializing. This raises an error when we try to access a missing exception key. A simple solution is not to rely on the hash's default value, and provide a default as alternative when accessing it instead.
* Support in-flight jobs stored before individual execution counters for ↵Rosa Gutierrez2019-01-051-4/+11
| | | | | | | | | | | | | | | | | | | | `retry_on` (#34731) Also, make tests and examples for individual execution counters clearer, as it wasn't entierly clear what would happen in this case: ``` retry_on CustomException, OtherException, attempts: 3 ``` The job would be retried at most 3 times in total, for both CustomException and OtherException. To have the job retry 3 times at most for each exception individually, the following retry_on declarations are necessary: ``` retry_on CustomException, attempts: 3 retry_on OtherException, attempts: 3 ```
* Keep executions for each specific exception (#34352)Alberto Almagro2018-11-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Keep executions for each specific declaration Fixes #34337 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 `attemps` number. **Example:** Having the following job: ```ruby class BuggyJob < ActiveJob::Base retry_on CustomException, attemps: 3 retry_on OtherException, attempts: 3 end ``` If the job raised `CustomException` in the first two executions and then it raised `OtherException`, the job wasn't retried anymore because the global executions counter was already indicating 3 attempts. With this patch each `retry_on` declaration has its specific counter so that the first two executions that raise `CustomException` don't affect the retries count that future exceptions may have. * Revert "clarifies documentation around the attempts arugment to retry_on" This reverts commit 86aa8f8c5631f77ed9a208e5107003c01512133e.
* Extract `instrument` method.Kasper Timm Hansen2018-09-231-26/+11
| | | | Similar to Action View's and Action Controller's instrument helpers.
* `retry_job` should publish `enqueue_retry.active_job` notificationbogdanvlviv2018-09-161-11/+17
| | | | | | | | | | Also this commit removes `:wait` from payload of `retry_stopped.active_job`. Related to https://github.com/rails/rails/pull/33751#discussion_r214140008 Follow up #33751 /cc @kaspth, @rafaelfranca
* clarifies documentation around the attempts arugment to retry_onGraham Turner2018-09-091-1/+3
|
* Move ActiveJob retry and discard logging into log subscriberSteve S2018-08-301-5/+3
|
* Add hooks to ActiveJob around retries and discardsSteve S2018-08-291-7/+25
|
* Allow passing multiple exceptions to retry_on/discard_onGeorge Claghorn2018-06-251-7/+7
|
* Fix name of the second parameter of block executed by `discard_on` and ↵bogdanvlviv2018-05-291-4/+4
| | | | | | | | `retry_on` [ci skip] Follow up #32854 and ba07b5fc12a740d41d288bea6347f15f4948483c.
* Pass the error instance as the second parameter of block executed by ↵yuuji.yaginuma2018-05-121-1/+1
| | | | | | | | | | | `discard_on` I'm not sure what originally wanted to pass to the argument. However, as long as see the document added along with the commit, it seems just to be mistaken that trying to pass the error instance. https://github.com/rails/rails/pull/30622/files#diff-59beb0189c8c6bc862edf7fdb84ff5a7R64 Fixes #32853
* Merge branch 'master' into custom-discarded-job-handlingAidan Haran2017-12-091-1/+1
|\
| * Yield with an error instance instead of error classKazunori Kajihiro2017-09-291-1/+1
| |
* | Allow for custom handling of exceptions that are discardedAidan Haran2017-09-161-1/+11
|/
* [Active Job] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveJobKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* add missing closing tag [ci skip]yuuji.yaginuma2016-10-141-1/+1
|
* correct exception class in `retry_on` example [ci skip]yuuji.yaginuma2016-08-201-2/+2
| | | | | If the deadlock has occurred `ActiveRecord::Deadlocked` will raise. Ref: #25107, #26059
* Yield the job instance so you have access to things like `job.arguments` on ↵David Heinemeier Hansson2016-08-161-3/+3
| | | | the custom logic after retries fail
* applies new string literal convention in activejob/libXavier Noria2016-08-061-1/+1
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Fix tests against ActiveSupport::DurationsDavid Heinemeier Hansson2016-08-021-4/+9
|
* Please RubocupDavid Heinemeier Hansson2016-08-021-3/+3
|
* Allow for custom handling of exceptions that persist beyond the retry attemptsDavid Heinemeier Hansson2016-08-011-4/+14
|
* Add exponentially_longer and custom wait algorithmsDavid Heinemeier Hansson2016-08-011-3/+25
|
* Reraise instead of swallow exceptions that occur beyond the retry attemptsDavid Heinemeier Hansson2016-07-291-1/+2
|
* Proper logging when we bail on retrying after X attemptsDavid Heinemeier Hansson2016-07-291-2/+6
|
* Allow retries to happen with different priority and queueDavid Heinemeier Hansson2016-07-291-2/+4
|
* Require time extension for 3.seconds defaultDavid Heinemeier Hansson2016-07-291-0/+2
|
* Mention defaultsDavid Heinemeier Hansson2016-07-291-2/+2
|
* Satisfy pedantic rubocop whitespace detectionDavid Heinemeier Hansson2016-07-291-2/+2
|
* Remove needless requireDavid Heinemeier Hansson2016-07-291-2/+0
|
* Add retry_on/discard_on for better exception handlingDavid Heinemeier Hansson2016-07-291-0/+78