bigquery: `query()` never uses the `jobs.query` fast path when `jobTimeoutMs` is set
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- typescript
调研方向
从 handwritten/bigquery/src/bigquery.ts 中的 buildQueryRequest_() 开始,这里 denylist 控制着 jobs.query 的 fast path。检查 handwritten/bigquery/src/types.d.ts 中的 IQueryRequest 定义以及现有的 createQueryJob() 映射,然后添加或更新相关的单元测试。当 jobTimeoutMs 通过 jobs.query 以字符串形式发送,并且测试验证 fast-path request 时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Library Name
@google-cloud/bigquery
A screenshot that you have tested with "Try this API".
The screenshots show the issue is client-side, not API-side:
jobs.queryacceptsjobTimeoutMsand returns results normally (HTTP 200).jobs.queryenforces it: a ~30s query withjobTimeoutMs: "1000"returns HTTP 499 with"Job execution was cancelled: Job timed out after 1 sec".
What would you like to see in the library?
This is a request for the handwritten client logic in handwritten/bigquery, not for the API surface: the API already supports the field, and the limitation is a client-side denylist.
Current behavior
BigQuery.query() routes queries to the accelerated jobs.query endpoint unless an option appears on a denylist in buildQueryRequest_().
jobTimeoutMs is on that list, so setting it silently forces every query through the slower jobs.insert + getQueryResults path:
// always goes through jobs.insert + polling, even for a tiny query
const [rows] = await bigquery.query({query: 'SELECT 1', jobTimeoutMs: 60000});
The API now supports jobTimeoutMs on jobs.query
- The
jobs.queryrequest body now has ajobTimeoutMsfield. This repository's generatedIQueryRequesttype already includes it: https://github.com/googleapis/google-cloud-node/blob/13d1ca8247789323094df9ed916e3ad184053cd7/handwritten/bigquery/src/types.d.ts#L4437-L4440 - The field's documentation explicitly covers the no-job case: "This timeout applies to the query even if a job does not need to be created."
Proposed change
Remove jobTimeoutMs from the denylist and map it into the IQueryRequest, converting the number to a string as the API expects an int64 field. This mirrors what createQueryJob() already does for the jobs.insert path.
A patch with a unit test is ready on my fork, based on current main. I will open a PR if the approach looks good: https://github.com/googleapis/google-cloud-node/compare/main...takaebato:google-cloud-node:bigquery-jobtimeoutms-fast-path
Describe alternatives you've considered
No real alternative: users today can only drop jobTimeoutMs or fall back to createQueryJob() and manage the job manually.
Additional context/notes
I verified the server-side behavior with direct REST calls.
1. jobTimeoutMs is enforced on the fast path, with the identical error as the slow path
A query that runs for roughly 30 seconds, submitted with a 1 second timeout via POST /projects/$PROJECT/queries:
{
"query": "SELECT COUNT(*) FROM UNNEST(GENERATE_ARRAY(1, 1000000)) a CROSS JOIN UNNEST(GENERATE_ARRAY(1, 1000)) b WHERE MOD(a + b, 7) = 0",
"useLegacySql": false,
"useQueryCache": false,
"jobTimeoutMs": "1000",
"timeoutMs": 120000
}
returns HTTP 499 synchronously after about 7 seconds:
{
"error": {
"code": 499,
"message": "Job execution was cancelled: Job timed out after 1 sec",
"errors": [
{
"message": "Job execution was cancelled: Job timed out after 1 sec",
"domain": "global",
"reason": "stopped"
}
],
"status": "CANCELLED"
}
}
The same query submitted via POST /projects/$PROJECT/jobs with {"configuration": {"query": {...}, "jobTimeoutMs": "1000"}} ends as DONE with an errorResult carrying the identical reason and message, and jobs.getQueryResults for that job returns a byte-identical HTTP 499 body. So the error surfaced to the client is the same regardless of path.
2. The timeout applies even when no job is created
The same fast path request with "jobCreationMode": "JOB_CREATION_OPTIONAL" added was cancelled as well, with the same error shape, confirming the documented behavior ("This timeout applies to the query even if a job does not need to be created").
3. The jobTimeoutMs: 0 case: only the request body changes, not the behavior
Before the patch, query({query, jobTimeoutMs: 0}) already took the fast path, because the denylist check is truthiness-based and 0 is falsy. The field was not sent in that case. With the patch, the field is sent as "jobTimeoutMs": "0". The server accepts "0" and treats it as "no timeout", so the observable behavior is the same, verified with
{"query": "SELECT 1", "useLegacySql": false, "jobTimeoutMs": "0"}
returning HTTP 200 with results. This also matches createQueryJob(), which has always sent "0" on the jobs.insert path.
- 主要语言
- TypeScript
- 星标
- 3.2k
- 派生
- 732
- 平均合并
- 2 天 11 小时
- 30 天内合并 PR
- 99
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
googleapis/google-cloud-node 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
googleapis/google-cloud-node#9854 ·
维护者通常 1 天内回复
-
pubsub: "Operation attempted on ended Span" when a modack is flushed after the message was acked未关闭api: pubsub
难度 2/5 1-3 小时 新手友好度 82/100
googleapis/google-cloud-node#9853 ·
维护者通常 1 天内回复
-
storage: V4 getSignedUrl sorts canonical headers with localeCompare, so they disagree with X-Goog-SignedHeaders可能已有人在做 @itsrayeedscodespace 于 9 天前认领。 未关闭api: storage
难度 2/5 1-3 小时 新手友好度 82/100
googleapis/google-cloud-node#9840 · 1 条评论 ·
维护者通常 1 天内回复
-
firestore: getPartitions() emits gax AutopaginateTrueWarning in every process可能已有人在做 @TheRealDanii 于 13 天前认领。 未关闭api: firestore
难度 2/5 1-3 小时 新手友好度 76/100
googleapis/google-cloud-node#9736 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
googleapis/google-cloud-node#9723 ·
维护者通常 1 天内回复
查看 googleapis/google-cloud-node 的全部 Issue
相似的 Issue
-
Type/Improvement
难度 2/5 1-3 小时 新手友好度 67/100
OpenNSW/nsw-srilanka#1259 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
oxc-project/tsrs#1010 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
Fission-AI/OpenSpec#2260 ·
维护者通常 1 天内回复
-
Add: ESP 1 UK未关闭check:passed streams:add
难度 1/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
area:infra area:storage bug
难度 2/5 1-3 小时 新手友好度 76/100
THU-MAIC/OpenMAIC#2311 · 1 条评论 ·
维护者通常 1 天内回复