Repository navigation
Announcement: Updated default retry behavior (2026) #2166
Replies: 2 comments
|
Use with opt-in flag |
Update: The updated retry behavior is now the defaultStarting in The opt-in is available in What this means for you
Restoring previous behavior In this SDK, We've updated the description with the new version information and revert instructions, and corrected some of the before-and-after values. If you run into unexpected behavior, comment here. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Important
Update: Starting in
aws-sdk-swiftversion1.8.24(released November 10, 2026), the updated retry behavior is the default and theAWS_NEW_RETRIES_2026environment variable is removed. To test the updated behavior before you upgrade, see How to opt in early. To restore previous behavior after you upgrade, see How to revert.Status
aws-sdk-swiftversion1.7.9and laterAWS_NEW_RETRIES_2026=true(removed in version1.8.24)aws-sdk-swiftversion1.8.24and later (released November 10, 2026)What changed
Starting in version
1.8.24(or earlier, if you setAWS_NEW_RETRIES_2026=true), the default retry mode changes fromlegacytostandard, and the retry defaults update per the table below. In this SDK,legacyandstandardmodes behave the same, including the DynamoDB max attempts default.adaptivemode also gets the updated defaults.If you have explicitly configured max attempts (
maxAttemptsin code,AWS_MAX_ATTEMPTS, ormax_attempts), your value takes precedence, unless you also supply your ownretryStrategyOptions, whosemaxRetriesBasesets max attempts. Your ownretryStrategyOptionsuse the updated behavior too, unless you create them withuseNewRetries2026: false, which keeps the previous base delays and retry quota costs. If you usebuilder(), it replaces theretryStrategyOptionsin the config that you pass towithConfig(_:). To set them on a builder, add.withPlugin(RetryPlugin(retryStrategyOptions: ...)).Transient errors (such as 500s and connection resets) now use a much shorter backoff than throttling errors (where the service asks you to slow down). For details on backoff timing, error classification, and the retry quota, see Retry behavior in the AWS SDKs. For retry mode selection and configuration options, see Retry behavior in the AWS SDKs.
How to opt in early
Update to
aws-sdk-swiftversion1.7.9or later, then set the environment variable:export AWS_NEW_RETRIES_2026=trueOnly the lowercase value
trueenables the opt-in.The opt-in doesn't preview some changes in
1.8.24: retries of HTTP 429 responses without a modeled error, the 4-attempt DynamoDB default for clients created withregion:orbuilder()or inlegacymode, and the updated behavior for your ownretryStrategyOptions.In version
1.8.24and later, the updated behavior is the default and the SDK ignoresAWS_NEW_RETRIES_2026. You can remove it from your configuration after you upgrade.How to revert
In versions earlier than
1.8.24, remove the environment variable:unset AWS_NEW_RETRIES_2026In version
1.8.24and later, the updated behavior is the default and the SDK ignoresAWS_NEW_RETRIES_2026, so unsetting it or setting it tofalsedoesn't restore the previous behavior.legacyretry mode doesn't restore it either. To restore the previous backoff timing, max attempts, and retry quota costs for a client, supply your ownretryStrategyOptionscreated withuseNewRetries2026: false:If you create clients with
builder(), pass the same options in aRetryPlugin:These options restore 3 attempts, a 1-second base delay for every error, and retry quota costs of 5 tokens (10 for timeouts), for DynamoDB too.
AWS_MAX_ATTEMPTSandmaxAttemptshave no effect on a client with its ownretryStrategyOptions. Three changes stay on: long-polling backoff, retries of HTTP 429 responses without a modeled error, andx-amz-retry-afterhandling. With these options, anx-amz-retry-aftervalue replaces the computed backoff, with no upper limit.To keep the updated behavior and change only max attempts, set
maxAttempts,AWS_MAX_ATTEMPTS, ormax_attempts. DynamoDB clients use your value as is, in every retry mode.If this is a concern for your use case, please let us know in this issue.
Where you might notice a difference
Transient errors recover faster because the base delay is significantly shorter.
SQS.ReceiveMessageapply a backoff delay before returning an error, even when retries are blocked. Without this, a polling loop would send its next request immediately after each error, spiking client CPU usage and generating additional traffic. You can't turn this off. For details, see long-polling operations.x-amz-retry-afterresponse header. When a service sends it, the SDK waits at least its own computed backoff and at most 5 seconds longer.standard.config.awsRetryModenow reads.standardby default.AWSRetryFeatures.isNewRetries2026Enabledis deprecated and alwaystrue.Overriding specific settings
If you want to keep a specific previous value, set max attempts explicitly, or supply your own
retryStrategyOptions. Your own options use the updated behavior unless you create them withuseNewRetries2026: false, which restores the previous base delays and retry quota costs. Long-polling backoff can't be turned off. Max attempts follows the usual precedence (code, thenAWS_MAX_ATTEMPTS, thenmax_attempts). Your ownretryStrategyOptionsreplace all retry settings at once, somaxAttemptshas no effect when you pass them.For example, to use the new backoff timing but keep a higher DynamoDB max attempts:
Set
maxAttemptsin the initializer. Changingconfig.maxAttemptsafterward doesn't affect clients created withDynamoDBClient(config:).For the full list of configurable settings and their precedence, see Retry behavior in the AWS SDKs.
Feedback
If you encounter unexpected behavior or have questions, comment on this issue. If you need a previous value that you can't configure, let us know here.
All reactions