feat(client): retry PermissionDenied on established connections (opt-in) - #1466
Open
sachinsharma3191 wants to merge 1 commit into
Open
Conversation
Add `retry_permission_denied_when_established` flag to `RetryOptions` (default: false). When enabled, `PermissionDenied` errors are retried only after at least one successful RPC has completed on the connection, proving that credentials were valid at some point. This handles transient auth failures on established connections (e.g. token rotation races, brief IAM propagation delays) without retrying genuinely unauthorized initial connections. The "established" state is tracked per-connection via an `Arc<AtomicBool>` set on first successful RPC response. Addresses temporalio#1448
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.
Summary
retry_permission_denied_when_establishedflag toRetryOptions(default:false), so existing behavior is unchanged.Arc<AtomicBool>onConnectionInner, set totrueafter the first successful RPC response.TonicErrorHandler::handle(),PermissionDeniedis retried only when both the opt-in flag is enabled and the connection is established — this handles transient auth failures (token rotation races, IAM propagation delays) without retrying genuinely unauthorized initial connections.PermissionDeniedonly;Unauthenticatedis left to credential refresh flows.Open design questions (for reviewer)
RetryOptions(flows throughConnectionOptions.retry_options). Alternative: a dedicated field onConnectionOptions. Current placement keeps retry concerns together.ConnectionInner(never resets on reconnect). This is intentional — if creds were valid once, aPermissionDeniedon a reconnected transport is likely transient. If reset-on-reconnect is desired, we'd need a callback from the transport layer.Addresses #1448
Test plan
permission_denied_not_retried_by_default— default behavior unchangedpermission_denied_not_retried_when_not_established— opt-in enabled but no successful RPC yet → not retriedpermission_denied_retried_when_established_and_opted_in— opt-in + established → retriedtemporalio-clientlib tests passtemporalio-sdk-corelib tests passcargo buildsucceeds