Skip to content

Commit

Permalink
Allow other retry configs to influence DynamoDB extended retries (#3175)
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp authored Jan 29, 2025
1 parent 4b4276d commit c0676b0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source 'https://rubygems.org'
gem 'rake', require: false
# SDK feature dependencies
gem 'aws-crt' if ENV['CRT']
gem 'base64'
gem 'http-2'
gem 'jmespath'
if defined?(JRUBY_VERSION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def build_keyword_arguments(plugins)
grouped = buffer.group_by { |name, _| name }
grouped.transform_values(&:count).find_all { |_, c| 1 < c }.each do |name,|
case name
when :endpoint, :endpoint_provider, :retry_limit, :disable_s3_express_session_auth, :account_id, :account_id_endpoint_mode
when :endpoint, :endpoint_provider, :retry_backoff, :retry_limit, :retry_base_delay, :disable_s3_express_session_auth, :account_id, :account_id_endpoint_mode
# ok
else
warn("Duplicate client option in #{@service_name}: `#{grouped[name].map { |g| g.values_at(0, 2) }}`", uplevel: 0)
Expand Down
2 changes: 2 additions & 0 deletions gems/aws-sdk-dynamodb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Issue - Allow other retry configs to influence DynamoDB extended retries.

1.134.0 (2025-01-15)
------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,49 @@ module Aws
module DynamoDB
module Plugins
class ExtendedRetries < Seahorse::Client::Plugin
DEFAULT_BACKOFF = lambda do |c|
return unless c.retries > 1

option(:retry_limit,
delay = 2**(c.retries - 1) * c.config.retry_base_delay
if (c.config.retry_max_delay || 0) > 0
delay = [delay, c.config.retry_max_delay].min
end
jitter = c.config.retry_jitter
jitter = Aws::Plugins::RetryErrors::JITTERS[jitter] if jitter.is_a?(Symbol)
delay = jitter.call(delay) if jitter
Kernel.sleep(delay)
end

option(
:retry_limit,
default: 10,
required: false,
doc_type: Integer,
docstring: <<-DOCS)
The maximum number of times to retry failed requests. Only
~ 500 level server errors and certain ~ 400 level client errors
are retried. Generally, these are throttling errors, data
checksum errors, networking errors, timeout errors and auth
errors from expired credentials.
DOCS
checksum errors, networking errors, timeout errors, auth errors,
endpoint discovery, and errors from expired credentials.
This option is only used in the `legacy` retry mode.
DOCS

option(:retry_backoff, default: lambda { |context|
if context.retries > 1
Kernel.sleep(50 * (2 ** (context.retries - 1)) / 1000.0)
end
})
option(
:retry_base_delay,
default: 0.05,
doc_type: Float,
docstring: <<-DOCS)
The base delay in seconds used by the default backoff function. This option
is only used in the `legacy` retry mode.
DOCS

option(
:retry_backoff,
default: DEFAULT_BACKOFF,
doc_type: Proc,
docstring: <<-DOCS)
A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
This option is only used in the `legacy` retry mode.
DOCS
end
end
end
Expand Down

0 comments on commit c0676b0

Please sign in to comment.