Skip to content

bugfix: DynamoDB retry defaults on the opt-in path - #3368

Merged
stobrien89 merged 2 commits into
aws:masterfrom
Alan4506:retries-ddb-defaults
Oct 12, 2026
Merged

stobrien89 merged 2 commits into
aws:masterfrom
Alan4506:retries-ddb-defaults

Conversation

@Alan4506

@Alan4506 Alan4506 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Description of changes:

The announcement says when AWS_NEW_RETRIES_2026=true is set, DynamoDB and DynamoDB Streams use 11 attempts in legacy mode and 4 in standard mode. However, when max_attempts is not set explicitly, both clients get the wrong counts:

AWS_NEW_RETRIES_2026=true, no max_attempts Observed Expected (#3285)
DynamoDB, AWS_RETRY_MODE=legacy 3 11
DynamoDB, AWS_RETRY_MODE=standard / adaptive 3 4
DynamoDB, 'retries' => ['mode' => 'standard'/'adaptive'] 3 4
DynamoDB Streams, AWS_RETRY_MODE=legacy 12 11
DynamoDB Streams, AWS_RETRY_MODE unset or =standard 12 4

Three causes, one fix each:

  1. Mode from env / shared config. DynamoDbClient::_defaultRetries() reads the mode through ConfigurationProvider::env() and ini(). When max_attempts isn't set, those providers fill in the generic 3, and _defaultRetries() can't tell that 3 apart from a user-supplied 3, so it never applies the DynamoDB value.
    Fix: after the providers resolve, _defaultRetries() checks AWS_MAX_ATTEMPTS / max_attempts directly via ConfigurationResolver::resolve(). If neither is set, it replaces the attempt count with 11 (legacy) or 4 (standard / adaptive) for the resolved mode.

  2. Mode from the client retries array. DynamoDbClient::_applyRetryConfig() gets its config from ConfigurationProvider::unwrap(), which fills in 3 for an array without max_attempts. The legacy branch already corrects this to 11 in resolveLegacyModeMaxRetries(); the standard / adaptive branch didn't.
    Fix: a sibling resolveStandardModeConfig() applies the same check (flag on, array config, no max_attempts) and returns a config with 4.

  3. DynamoDB Streams ignores the flag. DynamoDbStreamsClient hardcodes retries.default = 11 with no opt-in check, so a Streams client with no retries option always builds the legacy middleware and never reads env / shared config.
    Fix: DynamoDbStreamsClient now picks retries.default the same way DynamoDbClient does: DynamoDbClient::_defaultRetries when the flag is on, 11 when it is off.

Testing:

tests/Retry/V3/RoutingTest.php: 6 new cases fail without the source changes; 24/24 pass with them. Full unit test suite also passes.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Alan4506
Alan4506 requested a review from a team as a code owner October 8, 2026 05:39
@Alan4506
Alan4506 force-pushed the retries-ddb-defaults branch from a3df1be to 943a6fe Compare October 8, 2026 05:57
Comment thread src/DynamoDb/DynamoDbClient.php Outdated
Comment thread src/DynamoDb/DynamoDbClient.php Outdated
Comment thread src/DynamoDb/DynamoDbClient.php Outdated
Comment thread tests/Retry/V3/RoutingTest.php Outdated
@stobrien89
stobrien89 merged commit 9cb49b9 into aws:master Oct 12, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants