diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index c3b813d123f..a5f72910628 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -79,9 +79,9 @@ *Vlado Cingel* -* Add jitter to :exponentially_longer. +* Add jitter to `ActiveJob::Exceptions.retry_on`. - ActiveJob::Exceptions.retry_on with :exponentially_longer now uses a random amount of jitter in order to + `ActiveJob::Exceptions.retry_on` now uses a random amount of jitter in order to prevent the [thundering herd effect](https://en.wikipedia.org/wiki/Thundering_herd_problem). Defaults to 15% (represented as 0.15) but overridable via the `:jitter` option when using `retry_on`. Jitter is applied when an `Integer`, `ActiveSupport::Duration` or `:exponentially_longer`, is passed to the `wait` argument in `retry_on`. diff --git a/activejob/lib/active_job/exceptions.rb b/activejob/lib/active_job/exceptions.rb index d51c4bda4e8..3da764742ff 100644 --- a/activejob/lib/active_job/exceptions.rb +++ b/activejob/lib/active_job/exceptions.rb @@ -23,7 +23,7 @@ module ActiveJob # ==== Options # * :wait - Re-enqueues the job with a delay specified either in seconds (default: 3 seconds), # as a computing proc that the number of executions so far as an argument, or as a symbol reference of - # :exponentially_longer, which applies the wait algorithm of ((executions**4) + (Kernel.rand((executions**4) * jitter))) + 2 + # :exponentially_longer, which applies the wait algorithm of ((executions**4) + (Kernel.rand * (executions**4) * jitter)) + 2 # (first wait ~3s, then ~18s, then ~83s, etc) # * :attempts - Re-enqueues the job the specified number of times (default: 5 attempts) # * :queue - Re-enqueues the job on a different queue