Skip to content

feat: new retries implementation#3269

Open
yenfryherrerafeliz wants to merge 2 commits intoaws:masterfrom
yenfryherrerafeliz:feat_new_retries
Open

feat: new retries implementation#3269
yenfryherrerafeliz wants to merge 2 commits intoaws:masterfrom
yenfryherrerafeliz:feat_new_retries

Conversation

@yenfryherrerafeliz
Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:

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

@yenfryherrerafeliz
Copy link
Copy Markdown
Contributor Author

I found a few some minor issues that I am addressing. One of them is that for dynamodb is still defaulting the mode to legacy due to how the configuration is created for dynamodb. Also some unused variables that I need to remove.

Comment thread src/DynamoDb/DynamoDbClient.php Outdated
/** @internal */
public static function _defaultRetries(): callable
{
return \Aws\Retry\ConfigurationProvider::chain(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can defaultProvider() not be used here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though on it, but how would you set the max attempts to four?, which is what is being handled here.

Comment thread src/RetryMiddlewareV2.php Outdated
Comment thread src/RetryMiddlewareV2.php Outdated
Comment thread src/RetryMiddlewareV2.php Outdated
Comment thread src/RetryMiddlewareV2.php Outdated
Comment thread src/ClientResolver.php Outdated
Comment thread src/RetryMiddlewareV2.php Outdated
Comment thread src/RetryMiddlewareV2.php Outdated
Comment thread src/RetryMiddlewareV2.php Outdated
Comment thread src/RetryMiddlewareV2.php Outdated
@yenfryherrerafeliz yenfryherrerafeliz force-pushed the feat_new_retries branch 2 times, most recently from 34dee09 to 2e9958a Compare April 21, 2026 14:12
Copy link
Copy Markdown
Member

@stobrien89 stobrien89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nit, but approved otherwise. Let's hold off on merging until we find out when customers will be notified about this

Comment thread src/RetryMiddlewareV2.php Outdated
$retryAfterHeader = $response?->getHeaderLine(
self::RETRY_AFTER_HEADER
) ?? null;
} elseif($value instanceof ResultInterface) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: space needed after elseif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the docblock was just incorrect- intval() returns an int, so it should have been returning an int previously

Adds an opt-in new retry behavior. Set AWS_NEW_RETRIES_2026=true to enable the new path.
When the env var is unset (the default), retry behavior is unchanged from previous releases.
With the flag enabled, the SDK switches the default retry mode from 'legacy' to 'standard',
adopts a throttling-aware token-bucket retry quota (cost 14 for non-throttling, 5 for throttling),
reduces the non-throttling base backoff to 50ms, checks max-attempts before quota, honors the
x-amz-retry-after header, sleeps without retrying on long-polling operations (SQS, SFN, SWF)
when the quota is exhausted, and lets custom deciders supplement (rather than replace) built-in
retryability checks. DynamoDB defaults to 4 attempts with a 25ms base; STS treats IDPCommunicationError
as transient; S3's existing custom decider keeps its socket carve-out. The flag is intended
as an opt-in for early adopters and will become the default in a future release.
Copy link
Copy Markdown
Member

@stobrien89 stobrien89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good- clean way to handle this. A few small things and one structural recommendation: Retry\Standard implies there will only be logic handling the standard retry mode, but the new middleware also handles adaptive. I would just put all of these in the Retry namespace and rename QuotaManager to something like RetryQuota.

public static function isEnabled(): bool
{
if (self::$enabled === null) {
self::$enabled = getenv(self::ENV) === 'true';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a bit more permissive with the value here. See \Aws\boolean_value()

Comment on lines +221 to +226
private static function appendLegacyModeRetries(
$value,
RetryConfigurationInterface $config,
array &$args,
HandlerList $list
): void {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing a few places in multi-line method signatures where the opening brace needs to be moved down:

Suggested change
private static function appendLegacyModeRetries(
$value,
RetryConfigurationInterface $config,
array &$args,
HandlerList $list
): void {
private static function appendLegacyModeRetries(
$value,
RetryConfigurationInterface $config,
array &$args,
HandlerList $list
): void
{

Comment on lines +250 to +254
if (
NewRetriesOptIn::isEnabled()
&& is_array($value)
&& !isset($value['max_attempts'])
) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only one, but I'd check for others:

Suggested change
if (
NewRetriesOptIn::isEnabled()
&& is_array($value)
&& !isset($value['max_attempts'])
) {
if (NewRetriesOptIn::isEnabled()
&& is_array($value)
&& !isset($value['max_attempts'])
) {

Comment thread src/ClientResolver.php
use Aws\Retry\ConfigurationInterface as RetryConfigInterface;
use Aws\Retry\ConfigurationProvider as RetryConfigProvider;
use Aws\Retry\Standard\OptIn as NewRetriesOptIn;
use Aws\Retry\Standard\RetryMiddleware as StandardRetryMiddleware;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommend a rename here since this middleware also handles adaptive mode

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