Repository navigation
fix(sql): honor LoopJoin and LIKE cancellation on 4.2 - #30863
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
LeftHandCold
left a comment
There was a problem hiding this comment.
复审结论:基于最新 aa160a4d3fa382aa3707c81d069e3a0114e6fe57,代码层面无未解决的阻断项,建议 Approve。当前账户与作者相同,不能提交正式自我 APPROVE,因此以 COMMENT 记录结论;不等同于 required CI 已通过。
本轮先发现并核实了旧 HEAD 31b29045 的真实回归:已有 BVT 中 SHOW VARIABLES WHERE ILIKE 和 SHOW COLLATION WHERE LIKE 返回 context canceled。随后 PR 在复审期间更新,新增请求入口的 ReplaceTopCtx → ResetQueryContext 正好关闭了该问题:刷新的是复用 Process 的当前请求执行 context,未修改所有调用者共享的 ReplaceTopCtx 语义,也没有在 LIKE 中忽略真正的取消。新测试固定同一 SQL 连接检查连续请求、多语句、nested SET、SQL_MODE 分段及精确结果;frontend 测试覆盖当前请求 live/canceled/deadline、旧 context 状态与解析失败边界。
完整覆盖九个变更文件。按 mo-self-review / mo-dev / unhappy-path-audit 核对了 LoopJoin 错误返回、临时 window 的独立清理指针、Reset/Free、LIKE 的匹配/NULL/selection 及 4.2 特有语义;未发现新增状态机、无界资源或明显性能回归。没有将 Main 的 PairCondition/Unicode 变化夹带到 4.2。
验证范围说明:
- 独立检查了原修复的原始 owning normal/race、exact race x100、真实 KILL/断连 worker+txn 退出和 LIKE benchmark 记录,并比对六个文件内容哈希;这些文件在新提交中未变化。
- 本轮对新增 frontend 修正完成调用链和全部测试代码复查、diff/格式检查;PR 描述报告的新一轮 frontend/embed normal/race 结果未在本轮重复执行,未冒充独立重跑。
- 新 HEAD 的远端 CI 仍在排队/运行;旧 HEAD 的红灯不能作为新 HEAD 已失败或已通过的结论。合并前仍须按仓库规则完成门禁。
- 仍是协作式取消,不保证中断单次正在执行的超大文本 regexp,也不声称让原 SQL 本身变快。
XuPeng-SH
left a comment
There was a problem hiding this comment.
Approve for aa160a4d3fa382aa3707c81d069e3a0114e6fe57 after reviewing all nine changed files and the request → Process → compiler/pipeline → LoopJoin/LIKE ownership paths. No blocking code finding.
- The implementation reuses the existing cancellation source,
vm.CancelCheck, query-context reset, and operator cleanup. It closes the non-yielding LoopJoin/LIKE polling gaps without another state machine or compatibility path. The temporary condition window now has explicit ownership independent of named return values. - The earlier SHOW cancellation regression is resolved at the request boundary. Independent same-connection SQL probes cover binary prepared LIKE execution, subsequent SHOW, parse failure, and reuse. Removing only the new reset reproduces
context canceled; the reviewed head passes. A separate live-context Eval-error probe detects the old window-cleanup defect and passes with the new ownership code. - Local targeted cancellation/context tests and the public SQL regression passed on macOS arm64 / Go 1.26.4. Independently inspected current-head CI shows all four changed owning packages passing race UT, non-race coverage UT passing, SCA reporting 0 issues, and both Compose PROXY and Pessimistic BVT passing, including the historical SHOW/LIKE regression cases. No unresolved technical review thread remains.
CI is still red: race UT fails TestGlobalCheckpoint2 at AllFlushExpected(now, 4000), while a catalog flush takes about 5.25 seconds. Later checkpoint cancellation is teardown after the assertion. There is no evidence tying this to the changed SQL paths, but I did not establish a preexisting failure through a controlled baseline reproduction. This approval does not bypass required CI.
Limits: cancellation remains cooperative and cannot interrupt one in-progress regexp match. Local alternating base/head LIKE benchmarks were too noisy under host contention to quantify performance changes. The original public KILL/disconnect worker-and-transaction acceptance was inspected and reused for the unchanged LoopJoin/LIKE files, not independently rerun here.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #30836. This is the affected 4.2 branch fix; the Main fix is submitted separately.
What this PR does / why we need it:
A no-output LoopJoin can keep scanning inside one Call, and text LIKE can evaluate a large vector without observing cancellation. Even after cancellation reaches the frontend, the worker and transaction can remain active. Observe the existing context at LoopJoin work boundaries and between LIKE matches; existing optimized LIKE loops check every 256 rows. Preserve the independent cleanup owner for temporary condition windows on error.
Also initialize the reused session Process at the actual request boundary. After replacing its top context,
doComQuerycalls the existingResetQueryContext. Previously, a completed request canceled its context, and the following frontend SHOW evaluated WHERE using that staleproc.Ctx. The added LIKE checks exposed this as spuriouscontext cancelederrors. Fresh/current canceled requests must remain canceled; refreshing the context must not revive them.This adds one reset call per request. No new state, goroutines, timers, matching algorithm, cache policy, or per-row work in the follow-up correction. Do not change low-level
ReplaceTopCtx, since compiler callers also use it with active pipeline contexts. Keep 4.2's existing SQL, Unicode/escape and error-code behavior.Current validation
Follow-up revision:
aa160a4d3fa382aa3707c81d069e3a0114e6fe57.Base/merge-base:
4b11cd642008a0fd86ee3087d788f9c057b8a11a. The follow-up repairs31b29045d5ea2c1c82432b0c71a521aee4eae0abwithout a rebase.1105/HY000: context canceled. Same-request multi-statement control passes. The final request-boundary regression also fails with the unfixed source overlay.Required gpt-6.1-sol / xhigh gates (actual CLI turn_context independently verified):
01a163ec-16a4-7691-a430-7ba50634337b, reviewed parent31b29045d5ea2c1c82432b0c71a521aee4eae0aband the request-boundary correction.01a163f9-245e-7952-b6b0-6c352fda55a9, complete nine-file diff SHA-25681d522a1341c903eaa7b82c7b7a0fca5b1621426de7f6f08b2f33ebfa30ef2d7..Validation limits
Original public cancellation acceptance on the 4.2 baseline/candidate showed KILL QUERY, KILL CONNECTION and confirmed disconnect release the worker and transaction, with connection reuse where applicable. Those remote acceptance runs are historical evidence from the original patch, not rerun measurements for this follow-up. Current tests revalidate request cancellation ancestry plus the real LoopJoin/LIKE cancellation and cleanup paths.
Current public regression uses one CN. Full proxy/pessimistic BVT and remote CI remain pending; local checks are not a claim that remote CI passed. A single in-progress Go regexp match is still not asynchronously preemptible, so this does not promise a fixed cancellation SLA for arbitrary single-row text. The original expensive query is not made intrinsically faster by this cancellation fix.