Repository navigation
Description
Description
When a Window query uses ordered spill and reaches the configured processLimitationSpillSize cap, the SQL client receives the internal execution-resource admission error (20101/HY000) instead of a stable resource-exhausted error (3015/HY000). This is reproducible on current main and is separate from the MergeOrder, Group, and Top paths covered by #27627.
Environment
- Branch:
main - Commit:
2305954d0bf4aa5f062adb8b9379e471240abab5 - Deployment: fresh embedded
1 Log + 1 TN + 1 CNcluster - CN limits:
GuestMmuLimitation=1GiB,ProcessLimitationSize=1GiB,ProcessLimitationSpillSize=8MiB - Session:
max_dop=1,sort_spill_mem=1 - Date: 2026-10-16
Steps to reproduce
Create a database, then run:
set role moadmin;
create database codex_27627_window;
use codex_27627_window;
set @@max_dop = 1;
set @@sort_spill_mem = 1;
create table window_probe (
id bigint not null,
k bigint not null,
payload varchar(2048) not null
);
insert into window_probe
select result, -result,
repeat(char(65 + mod(result, 26)), 2048)
from generate_series(1, 30000) g;
select id,
max(payload) over (
order by k rows between unbounded preceding and current row
)
from window_probe;For a normal control under the same settings, create window_control with the same schema, insert 100 generated rows using the same expression, and run the same Window query against it.
Actual behavior
The 30,000-row query returns:
Error 20101 (HY000): internal error: execution resource admission rejected: requested=2048 used=8387625 cap=8388608
It publishes zero result rows before failing.
Expected behavior
Return a client-safe resource-exhausted error (3015/HY000) identifying the Window spill disk budget, without exposing execution resource admission rejected or using generic internal error 20101.
Stability and controls
- Reproducer: 3/3 on the same fresh isolated cluster.
- Normal control: the identical Window query over 100 rows succeeded and returned all 100 rows.
- Failure state: zero rows were published;
SELECT 1on the same connection succeeded after each failure. - Fixture baseline: 30,000 rows, each with a 2,048-byte payload; spill cap 8 MiB and process memory cap 1 GiB.
Evidence
SQL-protocol probe on the commit above:
go test ./pkg/tests/issues/isolated -run '^TestCodexIssue27627WindowSpillMapping$' -count=1 -v -timeout=20m
control=window_control rows=100 result=success
fixture=window_probe rows=30000 payloadBytesPerRow=2048 spillCapBytes=8388608
attempt=1 publishedRows=0 mysqlCode=20101 sqlState=HY000 message="internal error: execution resource admission rejected: requested=2048 used=8387625 cap=8388608"
attempt=2 publishedRows=0 mysqlCode=20101 sqlState=HY000 message="internal error: execution resource admission rejected: requested=2048 used=8387625 cap=8388608"
attempt=3 publishedRows=0 mysqlCode=20101 sqlState=HY000 message="internal error: execution resource admission rejected: requested=2048 used=8387625 cap=8388608"
The probe was run in a disposable isolated worktree and was not committed.
Code analysis
pkg/sql/colexec/window/window.go returns the error from ctr.processOrder directly from Window.Call (around lines 400-401). The ordered spill call in processOrder returns the admission error directly (around lines 2483-2494); the Window boundary does not normalize it through TerminalBudgetErrorForOperator.
Regression coverage
After the fix, add SQL-protocol regression coverage for the Window ordered-spill path. Assert 3015/HY000, zero published rows, a successful same-session control, and the normal small-input Window result.
Related
- Source issue: [Bug]: spill-disk admission rejection surfaces as 20101 for ORDER BY, GROUP BY and TOP #27627 (original
MergeOrder,Group, andToppaths pass on the tested main commit).
Activity
fix(window): normalize spill admission errors (#30397)
Ariznawlll commentedon Oct 16, 2026
测试版本
47b9690d7caec56b589fdefaf0684177412cffb2;修复 PR #30397 已合入,merge commit8669eedae682f7aea093c6cab3d1b8877f91a8dc已确认进入该 SHA。processLimitationSpillSize=8 MiB;会话max_dop=1、sort_spill_mem=1。原问题验证
保持 issue 原 SQL:30,000 行、每行 2,048 字节 payload(约 58.6 MiB,超过 8 MiB 限额),执行 ordered Window
max(payload) over (order by k rows between unbounded preceding and current row)。SQL 协议诊断探针独立启动 3 次、每次原查询执行 3 次,共 9/9 返回3015/HY000;每次 0 行提前发布,消息为window spill disk budget exceeded且limit=8388608,没有 20101 或内部 admission 文案。一次实际错误为requested=2048, used=8387625, limit=8388608,说明确实触达原阈值。Happy Path 覆盖
SELECT 1:9/9 返回 1,连接和 CN 仍可用。Unhappy Path 覆盖
3015/HY000,0 行发布,不泄露内部错误;只读查询不涉及写入原子性。白盒验证
此次以外部 SQL 协议验收为准;本地诊断探针未提交为 MatrixOne Go UT。未执行
-race(非并发竞争问题)。回归测试
d2ba6b0f2bfaab3e3d6639f4095922e3f9a6d005,文件suites/scenarios/14_issue_regression/issue_30391_window_spill.py与out/issue_30391_window_spill.out;未修改 (AOE) incompatible bug fix #237。保持 30,000×2,048 字节和 8 MiB 阈值,断言正常窗口值、3015、0 已发布行和同连接恢复。--repeat 3:3/3 success、0 failed、0 skipped;脚本直接运行另 3/3。未显式设置专用配置标志的普通环境 SKIP 77,不能计作通过。测试证据
publishedRows=0 code=3015 state=HY000,消息包含window spill disk budget exceeded (requested=2048, used=8387625, limit=8388608)。total=3 success=3 failed=0 skipped=0。离线检查不等于专用配置集成测试。测试结论
测试通过。
daviszhen commentedon Oct 20, 2026
最新 main 验证(2026-10-20)
基线:
309f618995af4ee23e3b9149365f4af77264090d;关联修复 PR:#30397。结论:原问题已解决。window forced-spill UT 通过,之前的 exact-main 集成证据也确认 spill 错误返回正确的 OOM/3015 映射。