From 895c39fe964333b26240193c811154461003280d Mon Sep 17 00:00:00 2001 From: Aditya Narsapurkar Date: Wed, 11 Mar 2020 21:47:53 +0530 Subject: [PATCH] Updates to ActiveJob::Exceptions.retry_on with jitter documentation [skip ci] - Changelog updated - Method documentation updated --- activejob/CHANGELOG.md | 4 ++-- activejob/lib/active_job/exceptions.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index 1a754a070b..5b623fdb08 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -69,9 +69,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 d51c4bda4e..3da764742f 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