Skip to content

[4.2.1-hotfix] fix(window): reuse unbounded aggregate frames - #31581

Merged
XuPeng-SH merged 1 commit into
matrixorigin:release/v4.2.1-hotfix-20261026from
XuPeng-SH:codex/issue-31530-421
Oct 28, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:release/v4.2.1-hotfix-20261026from
XuPeng-SH:codex/issue-31530-421

Conversation

@XuPeng-SH

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:

Addresses #31530 on release/v4.2.1-hotfix-20261026.

What this PR does / why we need it:

Backport #31546 to the active 4.2.1 hotfix branch. Aggregate windows currently rescan unbounded frames for every output row, causing quadratic aggregate work, including with a LIMIT above the Window operator.

Compute a whole-partition aggregate once and broadcast its result. Reuse independent unfinalized states for supported cumulative COUNT/SUM/AVG and fixed-width MIN/MAX frames; RANGE includes the complete peer group. Preserve the existing evaluator for unsupported cumulative aggregates and frames, and keep the target branch's unrelated vector and lifecycle code unchanged.

Validation on the target branch, macOS arm64 and Go 1.26.4:

  • Full Window package passed normally and with -race; tests cover aggregate values, NULLs, peers, partition isolation, varlen/DISTINCT full frames, work counts, cancellation and allocation failures.
  • Exact public SQL BVT passed twice on a two-CN cluster: 20/20 each, no skipped or failed statements, with database cleanup checked on both CNs.
  • Incremental 31-package go vet, molint and configured golangci-lint passed; lint reported zero issues. Molint printed six diagnostics in unchanged frontend/compile files; the same six were reproduced against the target baseline.
  • Same local SQL harness, target baseline versus backport, 8,000 rows: full SUM 10.708 s → 1.639 ms, cumulative SUM 5.323 s → 1.952 ms, full COUNT 332.37 ms → 0.285 ms; returned values checked. These are single observations on separate local cluster starts, not a statistical no-regression benchmark. The UT also checks aggregate work counts.
  • gpt-6.1-terra/max design and final overall review completed.

Unsupported cumulative DISTINCT, variable-length MIN/MAX and other unsupported states, and frames ending at a non-current offset retain the generic evaluator. CI remains separate.

@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner October 28, 2026 09:56
@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 →

@mergify mergify Bot added kind/bug Something isn't working kind/enhancement labels Oct 28, 2026
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: e6e6cdb1d60d1963f4630f71ea7eee8fbd765172

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: e6e6cdb1d60d1963f4630f71ea7eee8fbd765172

Assessment: approve

The backport preserves aggregate, peer, partition and cleanup contracts while removing quadratic work from supported unbounded frames. No actionable findings remain.

Model: gpt-6-astra / xhigh

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

Validation:

  • Seven focused tests passed normally and with race detection; each also passed 100 race repetitions. All 82 owning-package tests passed in both modes.

  • All 20 SQL fixture statements and expected results passed through each of two CNs, including prepared reexecution and database cleanup.

  • Package build and vet passed. Matched baseline/candidate benchmarks confirmed substantial improvements, with the bounded-frame control remaining comparable.

  • Reconciled 21 terminal receipts and retained logs in attempt-1/validation-audit.json. The initial SQL harness extraction error was corrected and its failed run excluded. All three discussion entries were assessed.

Limitations:

  • Validation ran on Linux; the author's macOS claims were not independently reproduced.

  • SQL used a retained Go/MySQL harness rather than mo-tester. Benchmark samples establish local improvements, not production latency guarantees.

@XuPeng-SH
XuPeng-SH merged commit f6a2794 into matrixorigin:release/v4.2.1-hotfix-20261026 Oct 28, 2026
3 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/issue-31530-421 branch October 28, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant