Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[java-bigquery] getQueryResults does not retry a SocketTimeoutException (read timeout)

未关闭 适合新手
#14,579 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
gcp, google-cloud, java
领域
api

调研方向

从 google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryBaseService.java 中的 BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER 开始,其中 retryOn 列出了 ConnectException、UnknownHostException 和 SocketException;SocketTimeoutException 缺失。检查该处理器在匹配之前是否会解包嵌套原因,然后使用相同的重试设置添加 read-timeout 情况(或其等价物)。完成的样子是:bigquery 模块中的一个单元测试断言,以 SocketTimeoutException 失败的 getQueryResults 调用会被重试,而不是在第一次尝试时抛出;gax 中断缺陷单独在 #12860 / PR #14578 中跟踪。

由索引模型根据 Issue 内容生成。

描述

Issue Details

BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER retries ConnectException, UnknownHostException and SocketException, but not SocketTimeoutException. So when one getQueryResults call inside Job.waitFor takes longer than the HTTP read timeout, the query fails at once with BigQueryException: Read timed out, after one attempt. A read timeout on this idempotent poll is as transient as a SocketException, and the job itself is still running.

Job.waitFor calls getQueryResults with no timeoutMs, so BigQuery holds each call for up to 10 s. java-bigquery sets the HTTP read timeout to 60,000 ms by default. A poll that gets no answer within 60 s, most likely a connection that died, fails the whole query, although the job is still running and the next poll would succeed. A longer read timeout does not help a dead connection. Only a retry does.

Edited 2026-10-04: an earlier version said the default read timeout is 20,000 ms. It is 60,000 ms.

Today a second defect hides this one: gax turns the SocketTimeoutException into a thread interrupt, so the caller sees BigQueryException: java.lang.InterruptedException instead (#12860, PR #14578). With that gax fix applied, the same stall fails with Read timed out after one attempt. That remaining failure is this issue.

Expected: getQueryResults (and other idempotent reads) retries a SocketTimeoutException under the same retry settings as a SocketException.

Environment

  • OS Type and Version: macOS 26.6.2 (arm64)
  • Java Version and JDK Vendor: OpenJDK 25 (2025-09-16 LTS)
  • Deployment: a JVM server that calls BigQuery through com.google.cloud:google-cloud-bigquery, with Application Default Credentials.

Dependencies

  • Client library: com.google.cloud:google-cloud-bigquery 2.54.1 (not using libraries-bom). The handler is the same on main today.
  • Gax: gax and gax-httpjson 2.84.0
  • Auth: google-auth-library-oauth2-http 1.37.1 to 1.51.0
  • Google-Http-Java-Client: 1.47.1 to 2.2.0

Reproducer

  1. Build a BigQuery client with a short HTTP read timeout, for example 2 s, through HttpTransportOptions.
  2. Run a query, and call job.waitFor() while BigQuery holds getQueryResults (any query that takes more than 2 s).
  3. With a gax that has the #14578 fix, waitFor throws BigQueryException: Read timed out (cause java.net.SocketTimeoutException) after one attempt. With current gax, it throws BigQueryException: java.lang.InterruptedException.

The same wait with the default timeout succeeds. The handler in question is in google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryBaseService.java:

.abortOn(RuntimeException.class)
.retryOn(java.net.ConnectException.class)
.retryOn(java.net.UnknownHostException.class)
.retryOn(java.net.SocketException.class)
主要语言
Java
星标
2.1k
派生
1.2k
平均合并
2 天 10 小时
30 天内合并 PR
147

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

googleapis/google-cloud-java 的其他 Issue

查看 googleapis/google-cloud-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。