Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow other retry configs to influence DynamoDB extended retries #3175

Merged
merged 6 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
mullermp marked this conversation as resolved.
Show resolved Hide resolved
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|
mullermp marked this conversation as resolved.
Show resolved Hide resolved
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
Loading