apache/beam · error · RuntimeException
Unable to get BigQuery response after retrying %d times usin
Error message
Unable to get BigQuery response after retrying %d times using query (%s)
What it means
queryWithRetries executes a BigQuery query with a bounded retry loop (MAX_QUERY_RETRIES) over transient IOExceptions. If all retries are exhausted, it throws a RuntimeException 'Unable to get BigQuery response after retrying %d times using query (%s)' with the last exception attached.
Source
Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/testing/BigqueryClient.java:400
do {
if (lastException != null) {
LOG.warn("Retrying query ({}) after exception", bqQueryRequest.getQuery(), lastException);
}
try {
QueryResponse response = bqClient.jobs().query(projectId, bqQueryRequest).execute();
if (response != null) {
return typed ? getTypedTableRows(response) : response;
} else {
lastException =
new IOException("Expected valid response from query job, but received null.");
}
} catch (IOException e) {
// ignore and retry
lastException = e;
}
} while (BackOffUtils.next(sleeper, backoff));
throw new RuntimeException(
String.format(
"Unable to get BigQuery response after retrying %d times using query (%s)",
MAX_QUERY_RETRIES, bqQueryRequest.getQuery()),
lastException);
}
/** Creates a new dataset. */
public void createNewDataset(String projectId, String datasetId)
throws IOException, InterruptedException {
createNewDataset(projectId, datasetId, null);
}
/** Creates a new dataset with defaultTableExpirationMs. */
public void createNewDataset(
String projectId, String datasetId, @Nullable Long defaultTableExpirationMs)
throws IOException, InterruptedException {
createNewDataset(projectId, datasetId, defaultTableExpirationMs, null);
}View on GitHub (pinned to 12126d8942)
Solutions
- Inspect the wrapped lastException in the stack trace for the root cause (quota vs network vs auth).
- Verify network/proxy access to https://bigquery.googleapis.com from the test host.
- Check BigQuery quotas/rate limits in Cloud Console; reduce test parallelism if rate-limited.
- Re-run the tests — these are transient-retry loops, so intermittent infra issues often clear.
- Increase MAX_QUERY_RETRIES or backoff for very large/slow test datasets if appropriate.
Example fix
// before
client.queryWithRetries(query, projectId); // throws after MAX_QUERY_RETRIES
// after
try {
client.queryWithRetries(query, projectId);
} catch (RuntimeException e) {
LOG.warn("BigQuery query failed after retries; retrying once after backoff", e);
Thread.sleep(10_000);
client.queryWithRetries(query, projectId);
} Defensive patterns
Strategy: retry
Validate before calling
// pre-flight connectivity check
Process p = Runtime.getRuntime().exec(new String[]{"curl", "-sSfo", "/dev/null",
"https://bigquery.googleapis.com/"});
boolean reachable = p.waitFor() == 0; Try / catch
try {
client.queryWithRetries(query, projectId);
} catch (RuntimeException e) {
if (e.getCause() instanceof IOException) {
LOG.error("BigQuery unreachable or quota-exhausted; root cause:", e.getCause());
}
throw e;
} Prevention
- Check BigQuery quotas and rate limits before large parallel test runs.
- Verify network egress to bigquery.googleapis.com in CI sandboxes.
- Inspect the wrapped cause to classify quota vs auth vs network issues.
- Throttle test concurrency that issues many simultaneous queries.
When it happens
Trigger: bigquery.jobs().query() throwing IOException on every attempt up to MAX_QUERY_RETRIES while running queryWithRetries/queryWithRetriesUsingStandardSql — e.g. persistent network failure, quota/rate errors surfaced as IOException, or an invalid query that always fails.
Common situations: CI machines with flaky or blocked network access to bigquery.googleapis.com; exhausted BigQuery API quota; transient Google outages; project-level rate limits during parallel IT runs.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- Unable to get BigQuery response after retrying %d times for
- Unable to get BigQuery response after retrying %d times for
- Unable to get BigQuery response after retrying %d times for
- Unable to verify project with ID ${projectId}
- Unable to get project number
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/3b45dd559675e5e6.
Report an issue: GitHub.