Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retry ExceptionHandler not retrying on IOException #3668

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

PhongChuong
Copy link
Contributor

@PhongChuong PhongChuong commented Feb 10, 2025

This PR fix an issue where the retry algorithm did not retrying based on the BIGQUERY_EXCEPTION_HANDLER configuration. This is caused by HttpBigQueryRpc translating IOExceptions into BigQueryException does not match the configurations set by BIGQUERY_EXCEPTION_HANDLER. To resolve this, we implement new internal methods (.*SkipExceptionTranslation) in HttpBigQueryRpc which do not translate the IOException. All retryable calls to HttpBigQueryRpc are updated to use these new methods.

In addition,

  • To preserve existing BigQueryException structure, this PR updates BigQueryRetryHelper.runWithRetries to parse the IOExceptions thrown by the .*SkipExceptionTranslation methods and translate them into BigQueryRetryException. This is needed as the original HttpBigQueryRpc translate IOExceptions into BigQueryException.
  • To preserve return values in the BigQuery interface for special cases such as HTTP_NOT_FOUND, this PR updates BigQueryImpl to checks the error code and return the appropriate BigQueryException.
  • The unit test BigQueryImplTest.testCreateJobFailureShouldRetryExceptionHandlerExceptions verify that BIGQUERY_EXCEPTION_HANDLER exceptions (UnknownHostException & ConnectException) are being retried

Fixes b/394167052 ☕️

@product-auto-label product-auto-label bot added size: s Pull request size is small. api: bigquery Issues related to the googleapis/java-bigquery API. labels Feb 10, 2025
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Feb 10, 2025
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Feb 26, 2025
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Feb 26, 2025
@PhongChuong PhongChuong marked this pull request as ready for review March 6, 2025 16:40
@PhongChuong PhongChuong requested review from a team as code owners March 6, 2025 16:40
}

@Test
public void testCreateJobFailureShouldRetry() {
when(bigqueryRpcMock.create(jobCapture.capture(), eq(EMPTY_RPC_OPTIONS)))
public void testCreateJobFailureShouldRetryExceptionHandlerExceptions() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have similar testing for the TableDataWriteChannel that validates behavior for retryable IOException cases? That one's potentially more tricky as it is focused more on inline uploads rather than streaming inserts, despite the poorly chosen name.

Copy link
Contributor Author

@PhongChuong PhongChuong Mar 7, 2025

Choose a reason for hiding this comment

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

Good call out. TabelDataWriteChanel retry on SocketException which is not included in our BIGQUERY_EXCEPTION_HANDLER. I've added it to the general default retry behavior which is also used outside of TabelDataWriteChanel. I think this makes sense but we can move it into just have it within TabelDataWriteChanel if you think that is better.

Added retry tests to TableDataWriteChanelTest. PTAL.

Copy link
Contributor

@whuffman36 whuffman36 left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work on such a massive PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/java-bigquery API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants