Skip to content

fix(bigquery): wrap default ResultRetryAlgorithm to retry transient HTTP errors#13416

Open
jinseopkim0 wants to merge 2 commits into
mainfrom
fix-cancel-job-b467066417
Open

fix(bigquery): wrap default ResultRetryAlgorithm to retry transient HTTP errors#13416
jinseopkim0 wants to merge 2 commits into
mainfrom
fix-cancel-job-b467066417

Conversation

@jinseopkim0

@jinseopkim0 jinseopkim0 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

b/467066417, b/467066596

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

Copy link
Copy Markdown
Contributor

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 wraps the callable in BigQueryRetryHelper.runWithRetries with a translating callable that catches IOException and throws a BigQueryException. The feedback suggests refactoring the anonymous Callable class into a lambda expression to improve readability and conciseness.

@jinseopkim0 jinseopkim0 force-pushed the fix-cancel-job-b467066417 branch from 6e90263 to 3234b7c Compare June 10, 2026 17:49
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 updates BigQueryRetryHelper.java to wrap the execution of the callable in a translatingCallable. This wrapper catches any IOException thrown during the retry execution and translates it into a BigQueryException. There are no review comments provided, and the changes appear to be correct and complete.

@jinseopkim0 jinseopkim0 force-pushed the fix-cancel-job-b467066417 branch from 3234b7c to 7f7a7d7 Compare June 10, 2026 18:14
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 updates BigQueryRetryHelper to wrap callables in a translating callable that catches HttpResponseException and rethrows it as a BigQueryException. The reviewer noted that catching only HttpResponseException is too restrictive and suggested catching IOException instead to properly handle and retry other transient network issues.

@jinseopkim0 jinseopkim0 changed the title fix(bigquery): translate IOException to BigQueryException in runWithRetries to enable retries on HTTP errors fix(bigquery): translate HttpResponseException to BigQueryException in runWithRetries to enable retries on HTTP errors Jun 10, 2026
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 updates BigQueryRetryHelper.java to wrap the execution of the callable in a translating callable. This translating callable catches HttpResponseException and wraps it in a BigQueryException before rethrowing. There are no review comments, and I have no feedback to provide.

@jinseopkim0 jinseopkim0 requested a review from lqiu96 June 10, 2026 19:19
@jinseopkim0 jinseopkim0 marked this pull request as ready for review June 10, 2026 19:19
@jinseopkim0 jinseopkim0 requested review from a team as code owners June 10, 2026 19:19
@jinseopkim0 jinseopkim0 force-pushed the fix-cancel-job-b467066417 branch from 7f7a7d7 to f9b53b0 Compare June 10, 2026 20:10
@jinseopkim0 jinseopkim0 changed the title fix(bigquery): translate HttpResponseException to BigQueryException in runWithRetries to enable retries on HTTP errors fix(bigquery): wrap default ResultRetryAlgorithm to retry transient HTTP errors Jun 10, 2026
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 wraps the default BigQuery exception handler in BigQueryRetryHelper to explicitly retry on HttpResponseException for server error status codes (500, 502, 503, and 504). A new unit test is added to verify retries on 503 errors. The feedback suggests delegating createNextAttempt to the default algorithm instead of returning null to ensure robust timing logic delegation.

Comment on lines +130 to +134
@Override
public TimedAttemptSettings createNextAttempt(
Throwable previousThrowable, V previousResponse, TimedAttemptSettings previousSettings) {
return null; // Delegate timing to TimedRetryAlgorithm
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Instead of hardcoding return null; in createNextAttempt, it is safer and more robust to delegate the call to defaultAlgorithm.createNextAttempt(...). This ensures that if the default algorithm's timing logic is updated in the future (e.g., to handle specific headers or custom backoff), the wrapper will correctly preserve that behavior rather than silently discarding it.

Suggested change
@Override
public TimedAttemptSettings createNextAttempt(
Throwable previousThrowable, V previousResponse, TimedAttemptSettings previousSettings) {
return null; // Delegate timing to TimedRetryAlgorithm
}
@Override
public TimedAttemptSettings createNextAttempt(
Throwable previousThrowable, V previousResponse, TimedAttemptSettings previousSettings) {
return defaultAlgorithm.createNextAttempt(previousThrowable, previousResponse, previousSettings);
}

Comment on lines +74 to +76
if (algorithm == BigQueryBaseService.DEFAULT_BIGQUERY_EXCEPTION_HANDLER) {
algorithm = wrapDefaultAlgorithm(algorithm);
}

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 these changes be made on the specific RPCs that we want to add it to? I'm worried that this would retry on some non-query RPCs (e.g. createJob or something) which we may not want to retry.

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