Skip to content

fix(gax): adjust RetryAlgorithm logic for timeout v. exception#13243

Draft
whowes wants to merge 4 commits into
mainfrom
whowes/issue-12373-flaky
Draft

fix(gax): adjust RetryAlgorithm logic for timeout v. exception#13243
whowes wants to merge 4 commits into
mainfrom
whowes/issue-12373-flaky

Conversation

@whowes
Copy link
Copy Markdown

@whowes whowes commented May 20, 2026

The current RetryAlgorithm logic is susceptible to an edge case when a short RPC deadline is set near the end of polling. If an exception results from a too-short deadline, the exception thrown by the associated Future will be an ExecutionException rather than CancellationException. This likely causes flakiness observed in #12373 and #3277.

This change ensures that shouldRetryBasedOnTiming executes even when shouldRetryBasedOnResult is false (e.g. due to non-retriable exception). This way a CancellationException will be thrown instead if the overall timeout has been reached.

Resolves #12373

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the RetryAlgorithm to short-circuit the retry check when an operation succeeds and the result algorithm indicates no retry is necessary. This change prevents the timing algorithm from erroneously throwing a CancellationException on successful operations. New unit tests were added to verify both the short-circuiting behavior and the standard path. Feedback suggests adding a missing assertion to one of the new test cases to explicitly verify the return value of the retry decision.

@whowes whowes force-pushed the whowes/issue-12373-flaky branch from 32b949e to f648950 Compare May 20, 2026 20:34
@whowes whowes force-pushed the whowes/issue-12373-flaky branch from 3cff2d3 to 54b9310 Compare May 20, 2026 20:40
@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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.

[sdk-platform-java] flaky test: showcase test ITLongRunningOperation

1 participant