aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/cases/exceptions_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use ActiveJob 5.2 retry logic for old jobsJohn Hawthorn2019-04-221-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+20
| | | | | | 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.
* Rewrite ActiveJob exception tests so it runs with the real adaptersRosa Gutierrez2019-01-081-87/+78
| | | | | | | | | Previously, by extending ActiveJob::TestCase, the test adapter provided for tests was being used always, in all executions where supposedly different adapters were being used. As a consequence, some bugs visible only for some adapters might have gone undetected. This commit changes that, skipping queue adapters for which we can't test scheduling jobs with a delay.
* Support in-flight jobs stored before individual execution counters for ↵Rosa Gutierrez2019-01-051-6/+25
| | | | | | | | | | | | | | | | | | | | `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 ```
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-12/+8
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Keep executions for each specific exception (#34352)Alberto Almagro2018-11-231-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Increment execution count before deserialize argumentsyuuji.yaginuma2018-08-181-0/+8
| | | | | | | | Currently, the execution count increments after deserializes arguments. Therefore, if an error occurs with deserialize, it retries indefinitely. In order to prevent this, the count is moved before deserialize. Fixes #33344.
* Allow passing multiple exceptions to retry_on/discard_onGeorge Claghorn2018-06-251-0/+18
|
* 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
|\
| * Test exception message to ensure an exception instance is yieldedKazunori Kajihiro2017-10-131-1/+1
| |
* | Allow for custom handling of exceptions that are discardedAidan Haran2017-09-161-0/+7
|/
* [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
|
* fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-011-1/+1
|
* Yield the job instance so you have access to things like `job.arguments` on ↵David Heinemeier Hansson2016-08-161-2/+2
| | | | the custom logic after retries fail
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-15/+15
|
* applies new string literal convention in activejob/testXavier Noria2016-08-061-11/+11
| | | | | 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-28/+45
|
* Please RubocupDavid Heinemeier Hansson2016-08-021-2/+2
|
* Not neededDavid Heinemeier Hansson2016-08-011-1/+0
|
* Allow for custom handling of exceptions that persist beyond the retry attemptsDavid Heinemeier Hansson2016-08-011-0/+5
|
* Add exponentially_longer and custom wait algorithmsDavid Heinemeier Hansson2016-08-011-0/+39
|
* Use descriptive exception namesDavid Heinemeier Hansson2016-08-011-14/+14
|
* Reraise instead of swallow exceptions that occur beyond the retry attemptsDavid Heinemeier Hansson2016-07-291-1/+1
|
* Satisfy pedantic rubocop whitespace detectionDavid Heinemeier Hansson2016-07-291-4/+4
|
* Add retry_on/discard_on for better exception handlingDavid Heinemeier Hansson2016-07-291-0/+47