Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
89ca3dbbf6d594d7614b8e1ca80f6b0300ed3cd2
Other Environment Information
Linux/amd64, Go 1.27.1, accounted Group execution with local spill enabled. The deterministic reproduction below exercises the real Group operator, allocation account, and spill/reload path; it does not claim a separately reproduced public SQL failure.
Actual Behavior
When a retryable allocation-capacity error occurs after Group has committed a prefix of an input batch, it spills the resident groups and evaluates the entire batch again. The already committed prefix still reflects the first evaluation, while the remaining rows use the second evaluation. Volatile or side-effecting group expressions or aggregate arguments can therefore return incorrect results and perform extra side effects.
In a deterministic 512-row test, a real account allocation is rejected after the first 256 groups have been committed. An incrementing group expression is evaluated twice, performs 1,024 side effects, and the output keys are 1..256 and 769..1024 instead of 1..512. A capacity error during initial expression evaluation can also cause previously evaluated expressions to be replayed.
Expected Behavior
A successfully evaluated input batch should keep the same group and aggregate argument values throughout pre-publication capacity recovery. A partially evaluated batch must not be replayed when the engine cannot prove that doing so is safe.
Steps to Reproduce
Use a separate worktree so the reproducer does not modify an existing checkout. The test file from the linked PR can be run against the affected base:
git fetch origin pull/32368/head
git worktree add --detach /tmp/mo-group-capacity-repro 89ca3dbbf6d594d7614b8e1ca80f6b0300ed3cd2
cd /tmp/mo-group-capacity-repro
git restore --source=FETCH_HEAD -- pkg/sql/colexec/group/capacity_retry_evaluation_test.go
.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run '^TestGroupCapacityRecoveryRetainsEvaluatedInput$' ./pkg/sql/colexec/groupWith the project's normal CGo prerequisites available, the base test fails because expressions are evaluated twice; the linked PR passes the same regression. The test uses the existing allocation controller to reject a real allocation and verifies actual spill/reload.
Additional information
The failure was discovered while investigating #32060, but it is separate from that issue's integer DISTINCT performance report. Proposed fix: #32368. The PAD SPACE grouping and primary-key/functional-dependency issues discussed during the investigation are separate as well.
Activity
test: guard aggregate input behavior on 4.2 (#32376)
fix(group): preserve evaluated inputs across spill retries (#32368)
XuPeng-SH commentedon Nov 9, 2026
QA 交接(不代表验收通过)
关联修复 #32368 已于 2026-11-09T00:29:13Z 合入 main,merge SHA:692b50a3614720e57d13d6521891d2d802bcf6b7。修复 Group 在已发布输入前缀后发生容量拒绝时重新求值整批输入的问题:保留已成功求值的输入向量和 grouping-set 标记,从尚未发布部分恢复;求值中途失败返回原错误,不重放可能有副作用的表达式。
验证证据:作者报告当前 rebased tree 的完整 Group、共享资源预算包 normal/race(matrixone_test)及 Group/compile 静态检查通过;真实分配拒绝、adaptive spill、H0 DISTINCT、发布后终止错误和失败恢复后的 Reset/Prepare 复用控制覆盖结果与账户、spill 磁盘、文件描述符清理。原实现的重放回归及 adaptive 回归失败、修复后通过。评审在 c0c5455 的结论为 approve,未提出待完成开发项;评审未运行成功的 Go 测试,原始作者日志也未提供。本次仅核对远端记录,未本地实测。
验证限制:旧头的 HAKeeper/CDC 与 CN heartbeat CI 超时本地未复现,未完全归因,不能宣称 CI 全量通过;评审记录时新头核心 CI 仍 pending。较早的双 CN(同一进程)SQL/性能样本未全部在 rebase 后重跑,SpillRows 不能单独证明触发容量恢复,微基准不是生产性能保证。
建议 QA 优先用真实账户容量拒绝复核部分发布后 volatile/副作用表达式只求值一次、精确键和聚合值;覆盖 ROLLUP、partial Group/MergeGroup、DISTINCT、borrowed vectors、二次拒绝、求值失败及资源释放/复用。保留输入会占用内存到批结束,极端压力下原来重放纯表达式可完成的查询可能改为容量错误,这是明确边界。普通 spill/merge/reload 生命周期及多 CN 压力可补充回归。#32060 性能、PAD SPACE 和主键/函数依赖问题不在本修复范围,不据此判定完成。
MatrixAdventurer commentedon Nov 9, 2026
分级建议:
severity/s2 —— 容量恢复路径曾对已发布批次重复求值,带副作用/非幂等表达式时结果不确定,正确性缺陷,但需容量误差与该类表达式同时出现,面窄;修复 #32368 已入 main,剩验证收尾。
模块:pkg/sql/colexec/group。
疑似重复:未发现。
建议负责人(/pkg/sql/colexec CODEOWNERS):XuPeng-SH/aunjgr/aptend;验证由 assignee Ariznawlll 跟进。
本操作由LW授权的MOI智能体提交
slyunnn commentedon Nov 9, 2026
Regression and extended verification for #32369 (2026-11-09)
Verification Environment
origin/mainat test start,6a2b29954749d5a47820ed429cfa8a6c4793682f—fix(parser): allow native PREPARE of DESC/DESCRIBE (#32399). A fresh native build, binary metadata and SQLgit_version()agreed.1.27.1, macOSarm64and Linuxamd64component execution with matching native dependencies andmatrixone_testfor the Group/resource-budget tests.2 CN / 1 TN / 1 Log service / Proxy. Both CNs shared the native launcher process. Proxy127.0.0.1:6001, CN1127.0.0.1:16001and CN2127.0.0.1:16002were connectable and each executed regression SQL. PyMySQL used TCPCOM_QUERY, existing BVT used JDBC.What Was Covered
256groups in a512-row batch. Actual spill/reload completed with one group-root evaluation, one aggregate-argument evaluation, exactly512row effects per expression, all keys1..512and exact aggregate values.ROLLUP, partial Group/MergeGroup,DISTINCTdrain, borrowed input, adaptive spill and a second capacity rejection. Checked failed-recoveryReset/Preparereuse and account, mpool, spill-disk and file-descriptor cleanup.14focused test/subtest results passed on both platforms.488and422test/subtest passes respectively per mode, no failures or skips.513group results over16,385rows against an independent oracle withmax_dop=1and4, resident and spilling thresholds. CheckedROLLUP, empty/all-NULLinputs, invalid-column error1054and connection health.46/46statements on each endpoint. A temporary pre-fix production overlay failed the same direct regression with expression-call count2instead of1.Findings
Fix
692b50a3614720e57d13d6521891d2d802bcf6b7,fix(group): preserve evaluated inputs across spill retries, retains evaluated input during pre-publication recovery and returns partial-evaluation errors without replay. Retained input may reduce recovery headroom under extreme pressure, as documented by the accepted design. Fix PR #32368An independent native-build guard issue encountered during setup is tracked separately. Using an environment-variable cache setting allowed the unchanged target source to build successfully. Build issue #32420
MOTR / BVT Coverage
Reused
capacity_retry_evaluation_test.go, the complete owning packages,qexec/group_h0_spill.sqlandqexec/group_spill_max_depth.sql. Existing coverage directly detects the original defect, so no duplicate MOTR commit was added. SQL extensions ran concurrently in endpoint-specific databases. BVT ran serially because its runner performs shared database cleanup. All source worktrees remained unchanged and the owned topology was stopped.Final Conclusion
Fixed on the tested main build.
A capacity-boundary regression is required and completed using the minimum original
512-row fixture with deterministic rejection after256committed groups. The supplemental SQL fixture crossed batch boundaries. Further arbitrary data enlargement or a TKE big-data run is unnecessary for this defect.