Add a short-lived cache for non-recoverable errors - #4781
Open
ysaito1001 wants to merge 1 commit into
Open
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
ysaito1001
marked this pull request as ready for review
August 13, 2026 16:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This PR follows #4774 in the series to support consistent credentials refresh across credential providers. It brings
StaticStabilityCachein line with a later revision of the design, which protects a credentials source even in the event of non-recoverable errors.StaticStabilityCache+ AWS-land signals)aws-runtime)aws-config+ codegen (wiring)These PRs merge into the
ysaito/consistent-credentials-refreshfeature branch.Description
Non-recoverable refresh errors intentionally skip the refresh backoff so actionable errors (e.g. "reauthenticate") surface immediately. But that means an application that catches such an error and retries in a loop would call the credential source (e.g. STS) on every retry. To protect the source, the SDK must briefly cache the error and re-raise it to subsequent callers without re-contacting the source.
This PR adds a short-lived, jittered cache for non-recoverable errors to
StaticStabilityCache, separate from the existing refresh backoff. It adds no public API and changes no client default behavior on its own.Specifically, on a non-recoverable refresh failure, the cache stores the error with an expiry of
now + uniform_random(1s..=5s)and still raises it to the current caller. While that window is live, subsequent resolutions re-raise the cached error without contacting the source — the gate is checked after acquiring the single-flight refresh lock, before any source call. A successful refresh clears the cached error.Testing
aws-runtime/test-data/credential-refresh-tests.jsonto match the revised designmandatory_concurrent_non_recoverable_reuses_cached_error— concurrent callers on an expired credential: one performs the refresh and fails non-recoverably; the others reuse the cached error, so the source is contacted exactly once.jittered_error_cache_bounds— the cache window always falls in1..=5s, the invariant thedeterministic suite relies on.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.