Repository navigation
[4.2-dev] fix(window): retire inherited buffers at prepared reset - #31127
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 48b3174d8bd52c619ebb0ce92a46edae73da05cb
Assessment: approve
Reviewed the complete six-file delta and cleanup callers. Window correctly releases account-bound copies at Reset, detaches borrowed references, and preserves unaccounted buffer reuse. The design retains existing ownership and accounting authorities. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
Validation:
-
Reconciled commands, source fingerprints, exit receipts and logs in /home/xupeng/.local/state/mo-bot/jobs/0b5c8715f62181d48fadd199/attempt-1/receipt-audit.json. Isolation preflight and native builds from matching source inputs passed.
-
Focused regressions passed. Restoring only the base cleanup implementation reproduced retained-account failures after cancellation and aggregation errors.
-
All 77 top-level Window tests passed under race detection; both focused regressions passed 100 race repetitions each.
-
Binary-prepared integration passed normally, under race detection, and across two race repetitions, covering changed parameters, empty/nonempty reuse and connection usability.
-
The committed SQL fixture passed 22/22 statements twice through the embedded server's MySQL interface, including golden results and independent teardown verification.
-
Vet, formatting, diff and native-provenance checks passed. Source remained unchanged. Added work is confined to Reset-time vector cleanup; no per-row work was added.
Limitations:
-
Frozen CI was pending. The author's original 206-row fixture and broader validation claims lacked retained receipts and were not counted as verified.
-
SQL fixture validation used a diagnostic Go overlay, not standard mo-tester. No broad repository suite or performance benchmark was run.
-
The linked issue body was absent from frozen evidence; its stated contract was assessed through the PR description, source and regression fixtures.
…#32112) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #31089. Backports the Window lifecycle fix from #31127 to the 4.2.1 hotfix branch. ## What this PR does / why we need it: A prepared JOIN followed by a Window can leave account-owned input and expression buffers alive after execution. Window Reset clears their logical data but retains their backing, so allocation-account finalization reports an invariant failure and suspends admission for subsequent account-owning queries on the same CN. Release the Window-owned buffers belonging to an allocation account at Reset, detach the result wrapper's borrowed references, and clear freed expression slots. Continue reusing unaccounted buffers. The change scans Window's buffered vector slots at Reset; it does not add per-row work or change account admission policy. On base `87866e6d2822`, a three-row prepared JOIN with an unpartitioned cumulative SUM reproduced `allocation account invariant failure` (48 bytes, four allocations); a subsequent JOIN failed with `allocation account admission is suspended`. A direct Window/registry control reproduced the same transition and showed that freeing Window's retained buffers releases the suspension. The user's incident has not yet been correlated with this specific query shape. Validation on macOS arm64, Go 1.26.4, with native libraries built from this hotfix source: - Full Window package normal and race tests. - Public prepared SQL regression normal and race: literal and prepared JOIN/window queries, repeated and empty executions, result equality, and new connection authentication. - Window account regression: partitioned and unpartitioned execution, cancellation, direct Free, two generations, and unaccounted buffer reuse. - Incremental formatting, vet, repository error checks, molint and golangci-lint for the affected packages. GitHub CI is pending. The standalone customer workload and Linux runtime have not been tested in this local run.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31089.
What this PR does / why we need it:
Release Window-owned inherited account buffers at prepared Reset on 4.2-dev. This narrowly adapts main's existing cleanup policy without backporting its accounting migration or changing release's window result representation.
Cause and invariant
Window can copy HashJoin output while inheriting its allocation account. Prepared execution ends through Reset, so clearing logical lengths is insufficient: all backing owned by the ending account must be released before account terminal completion. Ordinary execution additionally calls Free and can hide this lifetime defect.
Regression coverage
Production change and cost
Reuse the existing allocation-selection authority to detect inherited account backing. Release owned input and expression copies, nil freed slots before reuse, and detach borrowed result-wrapper references without cleaning their payload twice. Preserve the legacy aggregate-result cleanup and retain reusable unaccounted buffers.
The change adds a vector-slot scan at Reset and retires account-bound backing at its required terminal boundary. It adds no per-row evaluation, copying, I/O, goroutines, retries or new accounting state. Accounted prepared executions allocate fresh backing for each account generation; unaccounted buffer reuse is unchanged. No disk, catalog, wire or configuration format changes.
Validation
The final rebase preserves the reviewed Window/lifecycle and regression files byte-for-byte. Operator race and SQL BVT evidence is reused; original/reduced prepared acceptance and static checks were rerun on the rebased heads. GitHub CI is pending.
The full affected-package golangci scan reports four baseline warnings (three
prealloc, onesqlclosecheck) inissue_26121_test.goandissue_29399_test.go. Both files are byte-identical to the target base. The incremental scan uses--new-from-revwith--whole-files, checks all changed files, and passes; full affected-package vet and molint pass.One local attempt timed out during tester/shared-cluster initialization before regression SQL execution under host I/O and swap pressure. The recorded bounded retry passed; production code, fixture policy and timeout budgets were not relaxed.