Repository navigation
Description
Description
The same materialized-CTE query, under the same processLimitationSpillSize limit, reports two incompatible MySQL errors when HashBuild spill-disk admission is rejected: either 3015 resource exhausted or 20101 internal error.
This was found while validating #26131. The original CTE reuse/cancellation issue is fixed; this report is only about terminal resource-error classification.
Environment
- Branch:
main - Commit:
1d7b6311ce91df0968da435bb405f3d68137c595 - Deployment: embedded 1 Log + 1 TN + 2 CN
- Both CNs:
processLimitationSize=1 GiB,processLimitationSpillSize=32 MiB,max_dop=1
Steps to reproduce
- Create a table with 800,000 rows and 19
BIGINTpayload columns. - Patch the table statistics to 100,000 rows so a multi-reference CTE is materialized and runtime spill is exercised.
- Execute the same two-consumer CTE query repeatedly, alternating the two CN entry points. The 800,000-row form exceeds the 32 MiB spill-disk budget.
- Record the MySQL error number, SQLSTATE and message.
The query shape is:
WITH c AS (
SELECT id, MAX(c1) c1, ..., MAX(c19) c19
FROM cte_wide WHERE id <= 800000 GROUP BY id
)
SELECT COUNT(*), MIN(a.id), MAX(a.id), MAX(a.c1), MAX(...)
FROM c a JOIN c b ON a.id = b.id;Actual behavior
Repeated executions of the identical query return both:
ERROR 3015 (HY000): error: resource exhausted: hash build spill disk budget exceeded
and:
ERROR 20101 (HY000): internal error: hash build budget admission rejected
No execution returns a partial result, and both CNs remain healthy.
Expected behavior
Every terminal spill-disk budget rejection should be classified consistently as 3015/HY000 resource exhausted, with actionable requested/used/limit details. An expected capacity limit must not escape as 20101 internal error.
Stability and controls
- Reproducer: repeated on the latest official
mainin one fresh 2-CN cluster; both mappings occurred multiple times for the same SQL and configuration. - Happy control: the 500,000-row form spills about 12.55 MiB, returns the exact expected result, releases all reserved spill bytes, and succeeds from both CNs.
- Failure atomicity: rejected executions returned zero rows; subsequent
SELECT 1and the accepted spill query succeeded on both CNs. - Duplicate search: [Bug]: hash build budget admission rejected #26454 is a false-admission/estimation regression on a different big-data join. It does not cover inconsistent
3015/20101classification for one materialized CTE query.
Evidence
Representative pair from the same fresh run:
3015/HY000: resource exhausted: hash build spill disk budget exceeded
20101/HY000: internal error: hash build budget admission rejected:
requested=1311516 used=32787900 cap=33554432
Related validation comment: #26131 (comment)
Code analysis
pkg/sql/colexec/hashbuild/errors.go:TerminalBudgetError converts a typed HashBuildBudgetError to moerr.NewResourceExhaustedf, but some distributed/materialized-CTE terminal path is still surfacing the raw admission error. The operator diagnostic and client-visible error therefore depend on which path propagates the rejection. This is an inference from runtime evidence and the current error-conversion code; the exact propagation edge still needs owner confirmation.
Regression coverage
After the fix, add a configured multi-CN integration regression that runs the same rejection through both CN entry points for at least three rounds and strictly asserts 3015/HY000, spill-specific cause, zero partial rows and post-error recovery. This needs a low spill cap and generated wide data, so it belongs in the configured Go issue/integration suite rather than default MOTR.
Related
- Parent validation: [Optimizer] TPCH Q15 executes the same multi-reference CTE twice #26131
- Closest but different issue: [Bug]: hash build budget admission rejected #26454
Activity
fix(compile): normalize materialized CTE spill rejection (#27109)
slyunnn commentedon Aug 24, 2026
Regression and extended verification for #27106 (2026-08-24)
Verification Environment
Validated against MatrixOne
origin/maincommit861a0f5ea6cf90cd278cf6d4cdb1c74234cf36039—feat: esql_tvf / sql_tvf table functions and ENGINE = ESQL|SQL foreign external tables (#27489).Related fix: #27109, merge commit
0fc87ec145574bca4ddd5b496e4349894a6e9f5d,fix(compile): normalize materialized CTE spill rejection.Topology:
1Log service +1TN service +2CN services +1Proxy service. Both CNs were restarted from clean state with static[cn.frontend]settingsprocessLimitationSize=1073741824(1GiB) andprocessLimitationSpillSize=33554432(32MiB).The three test endpoints were Proxy
127.0.0.1:26009, CN1127.0.0.1:26001, and CN2127.0.0.1:26002. The client used the MySQL protocol. Every validation connection explicitly set and verified@@max_dop=1.What Was Covered
800000rows with19BIGINTpayload columns.EXPLAINshowed oneSinkand twoSink Scanconsumers before the self-join.500000-row two-consumer CTE control completed successfully on Proxy, CN1, and CN2.800000-row CTE consistently returned MySQL3015/HY000resource exhaustion through Proxy, CN1, and CN2.800000-row rejection scenario for3consecutive rounds; no round returned the prior20101internal error.SELECT 1on the same connection.@@max_dop=1.Findings
The original low-spill materialized-CTE workload now has one client-visible terminal classification:
3015/HY000resource exhaustion. The former20101internal-error mapping did not occur in9repeated rejection executions across the three endpoints.Large-data regression was required and performed. The defect depends on materialized CTE fanout and spill-budget admission, so the issue's minimum stable workload of
800000wide rows under the32MiBspill cap was necessary; arbitrary larger data would not add relevant coverage.MOTR / BVT Coverage
No MOTR test or issue branch was added. The required
1GiBprocess limit and32MiBstatic spill limit are CN-startup settings, so a default MOTR SQL case would not faithfully establish the bug boundary.The configured end-to-end BVT used the exact materialized CTE shape with
MAX(c1)throughMAX(c19), a two-consumerc a JOIN c b ON a.id=b.id, and MySQL-protocol verification on Proxy, CN1, and CN2.Final Conclusion
Fixed. The fully configured
2 CN + Proxyenvironment completed the happy path and consistently classified every original large-data spill rejection as3015resource exhaustion, with post-error recovery intact. Large-data regression was required and completed because the failure boundary is spill-size dependent.Ariznawlll commentedon Aug 26, 2026
测试版本
main5bc051abc44f34ccb6813e2a0bb5585d5a1db67eprocessLimitationSize=1GiB、processLimitationSpillSize=32MiB原问题验证
创建 800,000 行、19 个 BIGINT payload 列的宽表。
EXPLAIN确认计划包含 1 个Sink和 2 个Sink Scan,命中 materialized CTE 双消费者路径。分别通过 Proxy、CN1、CN2 执行 800,000 行拒绝场景,每个入口连续 3 轮,共 9 次。9/9 均稳定返回:
3015 / HY000 resource exhausted: hash build spill disk budget exceeded (requested=1311516, used=32787900, limit=33554432);未再出现20101 internal error。Happy Path 覆盖
@@max_dop=1,git_version()均为5bc051abc。500000/1/500000,最后 payload 最大值为500019。Unhappy Path 覆盖
SELECT 1,9/9 恢复成功;CN/Proxy 未退出。白盒验证
TestMaterializedSpillBudgetUsesProcessLimits连续执行 3 轮通过,覆盖 spill disk/FD 上限、3015 分类、invalid budget 与资源释放。回归测试
测试证据
当前 main 上重新执行完整配置化场景:3 个入口的 500k Happy Path 全部成功,800k rejection 9 次错误码、SQLSTATE 和 spill 预算明细完全一致。
测试结论
测试通过。
Ariznawlll commentedon Aug 26, 2026
无需加入普通 MOTR/big-data:该问题依赖 CN 启动时 32MiB spill 静态配置,通用回归无法忠实建立边界;主库已有资源预算/错误分类 UT,并已在 2CN+Proxy 配置环境完成 500k Happy Path 与 800k 共 9 次拒绝验证。现关闭。
fix(compile): normalize materialized CTE spill rejection (matrixorigi…
fix(compile): normalize materialized CTE spill rejection (matrixorigi…
fix(compile): normalize materialized CTE spill rejection (matrixorigi…