Skip to content

fix(window): normalize spill admission errors - #30397

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
daviszhen:codex/fix-30391-window-spill
Oct 16, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
daviszhen:codex/fix-30391-window-spill

Conversation

@daviszhen

@daviszhen daviszhen commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #30391

What this PR does / why we need it:

Window ordered spill admission failures were returned directly as the internal execution-resource admission error, which exposed SQL error 20101 instead of the client-facing resource-exhausted error (3015).

This change applies the existing terminal budget-error mapping at the public Window.Call boundary and keeps lifecycle, cancellation, and non-admission errors unchanged. The forced spill tests now verify the 3015 mapping, the internal sentinel is not exposed, input rows remain intact, and spill reservations are released.

Validation:

make cgo
git diff --check
go test ./pkg/sql/colexec/window -run 'TestWindow(ConstantKeysWithForcedSpill|OrderSpillResourceAdmissionCleans)' -count=1

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@daviszhen

Copy link
Copy Markdown
Contributor Author

Reviewed latest head e1f547f907c74f5f7e95ab068c6c65addfbc736b (including the main merge).

No blocking findings in this change. Applying normalization at the public Window.Call boundary keeps the internal admission error available to spill/recovery code and reuses the existing client-facing resource-exhaustion mapping.

Validation performed in an isolated worktree:

  • Passed the disk/FD admission cleanup tests, the constant-key spill-admission subtest, and the TestTerminalBudgetError* tests.
  • Added a temporary review-only TCP SQL regression reproducing [Bug]: Window ORDER BY spill admission rejection returns 20101 instead of 3015 #30391 with 1 GiB memory limits, an explicit 8 MiB spill limit, max_dop=1, sort_spill_mem=1, and 30,000 rows with 2,048-byte payloads. All three attempts returned MySQL 3015 / HY000, included window spill disk, omitted the internal admission sentinel, and published zero rows. SELECT 1 succeeded on the same connection after each failure; the 100-row control query succeeded.
  • git diff --check passed.

Validation limitation: the unmodified full window suite was not green on this machine. Successful-spill cases hit requested=8, used=0, cap=1 because available disk was below the existing 16 GiB safety headroom. The same failures reproduced against the unchanged window implementation from the shared base, so I do not attribute them to this PR. The SQL regression above used an explicit spill limit and passed again on the latest head.

Non-blocking suggestion: retain a protocol-level regression like the above in the repository, so the external 3015/HY000 contract and same-connection recovery remain covered beyond the operator-level assertions.

Code-review recommendation: approve, subject to required CI passing. CI was still pending/running at review time; this is an ordinary review comment, not a formal approval.

@XuPeng-SH

XuPeng-SH commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: e1f547f907c74f5f7e95ab068c6c65addfbc736b

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: e1f547f907c74f5f7e95ab068c6c65addfbc736b

Assessment: approve

Reviewed the complete three-file delta, callers, cleanup paths, tests and supplied comments. Window.Call appropriately reuses the established terminal-error mapper, restoring the resource-exhaustion SQL contract without duplicating normalization inside spill machinery. Cancellation, lifecycle errors and resource ownership remain intact. Success-path overhead is one deferred mapping check per Call; no new per-row allocation or I/O was identified. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Eight targeted tests passed across window, hashbuild and moerr, covering disk/FD admission, constant-key spill, cancellation, reset/reuse, error mapping and serialization. Receipt: checks/1792158154411599802-3.json; log: focused-recovered.log.

  • Isolation preflight passed. Missing native prerequisites initially prevented testing; an exact-head diagnostic checkout was built through the repository owner, provenance verified, and testing then completed successfully.

  • Source fingerprints, clean checkout state, patch scope, formatting, commands, exit receipts and logs were reconciled. Evidence audit receipt: checks/1792158255092907474-4.json. Retained manifest: /home/xupeng/.local/state/mo-bot/jobs/9c23c5cab7b2c194c590263d/attempt-1/validation-manifest.json.

  • Frozen exact-head evidence reports successful Ubuntu unit tests, static analysis, coverage and proxy/pessimistic multi-CN BVT.

Limitations:

  • Raw CI logs were not supplied. The exact-head TCP SQL reproduction in comment 6213132613 was reviewed as reported evidence, not independently replayed.

  • Linked issue #30391's body was unavailable; its error-code contract was assessed from the supplied PR and comments.

  • No local full-suite, race, BVT or performance benchmark rerun was performed.

@mergify mergify Bot added the queued label Oct 16, 2026
@mergify

mergify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-16 13:45 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-16 14:04 UTC · at 0549adfe40dccc37a4667ede3a3d0250250f231a

This pull request spent 19 minutes 37 seconds in the queue, with no time running CI.

Reason

Pull request #30397 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Copy link
Copy Markdown
Contributor

最近 24 小时合并项复核(main aa4b6eddfdad54d11be6fd75a5675eb9801f6690):发现受影响的 spill 成功路径 UT 依赖真实宿主磁盘空闲容量,已创建 #30450。

在约 8.8 GiB 空闲空间的文件系统上,自动 spill 预算按既有 16 GiB emergency headroom 策略得到 cap=1;Group 的四个根测试隔离重复 3 次均失败(12/12),Window 的多个正常 spill 场景也在同样 cap=1 下失败。仅在 Group 测试夹具中显式设置 bounded spill 预算的临时 overlay,使相同 12 次执行全部通过,原结果和清理断言保持。

这是已复现的测试夹具宿主容量依赖;没有把它归因于本 PR 新引入,也没有认定生产磁盘保护策略错误。本 PR 的 Window 3015 错误映射/资源拒绝清理回归本轮通过;正常 spill 夹具问题仍需另外处理。详见 #30450 的命令、失败与对照数据。

This branch was previously deployed

1 inactive deployment
ci — 0549adfe Deployed Oct 16, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Window ORDER BY spill admission rejection returns 20101 instead of 3015

3 participants