Skip to content

Commit c0676b0

Browse files
authored
Allow other retry configs to influence DynamoDB extended retries (#3175)
1 parent 4b4276d commit c0676b0

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
55
gem 'rake', require: false
66
# SDK feature dependencies
77
gem 'aws-crt' if ENV['CRT']
8+
gem 'base64'
89
gem 'http-2'
910
gem 'jmespath'
1011
if defined?(JRUBY_VERSION)

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/rbs/client_class.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def build_keyword_arguments(plugins)
138138
grouped = buffer.group_by { |name, _| name }
139139
grouped.transform_values(&:count).find_all { |_, c| 1 < c }.each do |name,|
140140
case name
141-
when :endpoint, :endpoint_provider, :retry_limit, :disable_s3_express_session_auth, :account_id, :account_id_endpoint_mode
141+
when :endpoint, :endpoint_provider, :retry_backoff, :retry_limit, :retry_base_delay, :disable_s3_express_session_auth, :account_id, :account_id_endpoint_mode
142142
# ok
143143
else
144144
warn("Duplicate client option in #{@service_name}: `#{grouped[name].map { |g| g.values_at(0, 2) }}`", uplevel: 0)

gems/aws-sdk-dynamodb/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Issue - Allow other retry configs to influence DynamoDB extended retries.
5+
46
1.134.0 (2025-01-15)
57
------------------
68

gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/plugins/extended_retries.rb

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,49 @@ module Aws
44
module DynamoDB
55
module Plugins
66
class ExtendedRetries < Seahorse::Client::Plugin
7+
DEFAULT_BACKOFF = lambda do |c|
8+
return unless c.retries > 1
79

8-
option(:retry_limit,
10+
delay = 2**(c.retries - 1) * c.config.retry_base_delay
11+
if (c.config.retry_max_delay || 0) > 0
12+
delay = [delay, c.config.retry_max_delay].min
13+
end
14+
jitter = c.config.retry_jitter
15+
jitter = Aws::Plugins::RetryErrors::JITTERS[jitter] if jitter.is_a?(Symbol)
16+
delay = jitter.call(delay) if jitter
17+
Kernel.sleep(delay)
18+
end
19+
20+
option(
21+
:retry_limit,
922
default: 10,
10-
required: false,
1123
doc_type: Integer,
1224
docstring: <<-DOCS)
1325
The maximum number of times to retry failed requests. Only
1426
~ 500 level server errors and certain ~ 400 level client errors
1527
are retried. Generally, these are throttling errors, data
16-
checksum errors, networking errors, timeout errors and auth
17-
errors from expired credentials.
18-
DOCS
28+
checksum errors, networking errors, timeout errors, auth errors,
29+
endpoint discovery, and errors from expired credentials.
30+
This option is only used in the `legacy` retry mode.
31+
DOCS
1932

20-
option(:retry_backoff, default: lambda { |context|
21-
if context.retries > 1
22-
Kernel.sleep(50 * (2 ** (context.retries - 1)) / 1000.0)
23-
end
24-
})
33+
option(
34+
:retry_base_delay,
35+
default: 0.05,
36+
doc_type: Float,
37+
docstring: <<-DOCS)
38+
The base delay in seconds used by the default backoff function. This option
39+
is only used in the `legacy` retry mode.
40+
DOCS
2541

42+
option(
43+
:retry_backoff,
44+
default: DEFAULT_BACKOFF,
45+
doc_type: Proc,
46+
docstring: <<-DOCS)
47+
A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
48+
This option is only used in the `legacy` retry mode.
49+
DOCS
2650
end
2751
end
2852
end

0 commit comments

Comments
 (0)