GeezerVison is showing github.com — fix(bigquery): expand retry allowlist and propagate structured errors (#14579) by lqiu96 · Pull Request #32 · lqiu96/google-cloud-java
Conversation
lqiu96
commented
Oct 22, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
This pull request addresses the BigQuery exception handling and retry allowlist gaps identified in issue googleapis#14579.
Summary of Changes
- Transport Exception Allowlist: Adds
SocketTimeoutException and EOFException to DEFAULT_BIGQUERY_EXCEPTION_HANDLER in BigQueryBaseService. SocketTimeoutException is a subclass of InterruptedIOException rather than SocketException in the JDK hierarchy, and EOFException is a direct subclass of IOException. Both represent transient network failures that were previously omitted from the default handler.
- DirectRetryingExecutor Workaround: Adds
BigQueryDirectRetryingExecutor in BigQueryRetryHelper to catch SocketTimeoutException separately before InterruptedIOException. GAX DirectRetryingExecutor catches InterruptedIOException and calls Thread.currentThread().interrupt() before retryingFuture.setAttemptFuture(...), which causes BasicRetryingFuture to see the thread as interrupted and abort the retry loop with an InterruptedException instead of evaluating shouldRetry.
- Structured BigQuery Error Reasons: Expands
BigQueryException.RETRYABLE_ERRORS with the six core BigQuery SLA and error troubleshooting guide reasons (rateLimitExceeded, userRateLimitExceeded, jobRateLimitExceeded, backendError, internalError, and badGateway) and HTTP status codes 429, 500, 502, 503, and 504.
- Retryability Evaluation: Overrides
BigQueryException.isRetryable() to check RETRYABLE_ERRORS (including HttpResponseException status codes when getCode() is UNKNOWN_CODE) as well as SocketTimeoutException and EOFException causes.
- Centralized Retry Evaluation: Updates
BigQueryRetryAlgorithm.shouldRetryBasedOnResult to evaluate BigQueryException.isRetryable() and removes the 16 per-call-site BigQueryRetryHelper.maybeWrapForHttpRetry wrappers in BigQueryImpl.
- Query Polling Retryability: Updates
Job.waitForQueryResults to check ((BigQueryException) prevThrowable).isRetryable() when polling query results.
- Unit Tests: Adds unit tests in
BigQueryExceptionTest, BigQueryImplTest, and JobTest.
Interaction with SkipExceptionTranslation and maybeWrapForHttpRetry
-
Why SkipExceptionTranslation was introduced (PR Exception in thread "main" java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured googleapis/google-cloud-java#3668):
Originally, HttpBigQueryRpc caught IOException inside every RPC method and threw new BigQueryException(ioException) upfront. Because ExceptionHandler.shouldRetry only checks the top-level thrown exception class (ex.getClass()) against its retriableExceptions set and does not inspect ex.getCause(), wrapping an UnknownHostException into a BigQueryException hid the UnknownHostException class from DEFAULT_BIGQUERY_EXCEPTION_HANDLER. PR Exception in thread "main" java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured googleapis/google-cloud-java#3668 added the *SkipExceptionTranslation methods on BigQueryRpc so that the callable inside BigQueryRetryHelper.runWithRetries throws raw IOException during the retry loop, and translates to BigQueryException only after retries are exhausted.
-
Why SkipExceptionTranslation broke BigQueryException.RETRYABLE_ERRORS (PR fix(bigquery): retry cancel job and routine creation on transient HTTP 5xx errors googleapis/google-cloud-java#13416):
A side effect of PR Exception in thread "main" java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured googleapis/google-cloud-java#3668 was that GoogleJsonResponseException and HttpResponseException (which are subclasses of IOException, not BaseServiceException) were no longer translated into BigQueryException before DEFAULT_BIGQUERY_EXCEPTION_HANDLER evaluated them. Because BaseService.EXCEPTION_HANDLER_INTERCEPTOR only checks if (exception instanceof BaseServiceException), raw HTTP 500, 502, 503, and 504 responses bypassed BigQueryException.RETRYABLE_ERRORS and were only retried if their error message happened to match a regex in BigQueryRetryConfig. PR fix(bigquery): retry cancel job and routine creation on transient HTTP 5xx errors googleapis/google-cloud-java#13416 added BigQueryRetryHelper.maybeWrapForHttpRetry on 16 call sites in BigQueryImpl to translate IOException into BigQueryException when resultAlgorithm == DEFAULT_BIGQUERY_EXCEPTION_HANDLER.
-
How BigQueryRetryAlgorithm.shouldRetryBasedOnResult preserves both behaviors:
BigQueryRetryAlgorithm.shouldRetryBasedOnResult evaluates getResultAlgorithm().shouldRetry(previousThrowable, previousResponse) first on the raw previousThrowable.
- For
UnknownHostException, SocketException, SocketTimeoutException, and EOFException (as well as any custom ExceptionHandler or ResultRetryAlgorithm configured via BigQueryOptions.setResultRetryAlgorithm), getResultAlgorithm().shouldRetry(...) sees the raw IOException directly, preserving PR Exception in thread "main" java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured googleapis/google-cloud-java#3668 (SkipExceptionTranslation) and custom user retry configurations.
- Only when
getResultAlgorithm().shouldRetry(...) returns false and the caller is using DEFAULT_BIGQUERY_EXCEPTION_HANDLER does BigQueryRetryAlgorithm evaluate new BigQueryException((IOException) previousThrowable).isRetryable() as a read-only predicate (without mutating previousThrowable) to check HTTP status codes (429, 500, 502, 503, 504) and structured JSON error reasons (rateLimitExceeded, backendError, etc.) across all *SkipExceptionTranslation RPCs uniformly.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…omments, and remove unused helpers
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|