Repository navigation
fix(vector): preserve Area on admission failure for 4.2-dev - #28369
mergify[bot] merged 2 commits into
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head c7b7267 against 4.2-dev base/merge-base 588295f: APPROVE for the scoped Area-ownership backport.
Read every changed hunk across all eight files and traced unionBatchContiguousVarlenRange -> growArea2/growOwned -> MPool.Grow/reAllocWithDetailK -> Vector.Free, plus HashJoin Call/emptyProbe -> Reset/Free -> result-batch cleanup. The sole production hunk exactly matches upstream 17c161a. Allocation failure leaves the old allocation live; retaining v.area until growth succeeds preserves its destruction owner. Successful growth frees the old allocation before returning the replacement, which is then published once. Existing rows/length are untouched at this failure boundary because descriptor copying and length advancement occur afterward. Zero-length/nonzero-capacity Areas remain freeable by capacity and pointer.
The tests distinguish ownership aliases from cloned byte/value snapshots, cover success and denial with existing/reused Area plus selected/Append/UnionOne controls, and explicitly avoid promising atomic UnionOne append. The HashJoin fixture exercises real budget admission, result reuse and normal terminal cleanup. Both fixtures inspect account/live-allocation/budget state and subsequent admission before any test-only orphan reclamation, so cleanup cannot turn the original production leak into a passing oracle.
Q1: the vector remains the effective Area owner on failure, and HashJoin terminal cleanup reaches that owner. Q2: no new wait, lock, goroutine or cancellation protocol is introduced. Q3: no budget/admission policy is weakened or new retained state added; failed growth no longer strands accounted capacity. The successful hot path keeps the same allocation/copy work. This ordinary focused ownership fix does not require a new feature design; it changes no public/wire/catalog/storage format, tenant boundary or compiler algorithm.
Validation checked: current-head MatrixOne ALL CI 34195497999 succeeds (the earlier cancelled run is superseded), git diff --check passes, and its actual multi-CN pessimistic BVT log records merge_top_large_limit.sql 19/19 successful in 0.403s. The new 8 MiB isolated HashJoin admission fixture is correctly outside default CI and explicitly requires a disposable single-CN service and no JDBC auto-reconnect; its author-reported red/green and focused normal/race runs are not claimed as my own executions. The normal wide-varlen BVT is success-path coverage, not evidence of denial recovery or the omitted compiler rewrite.
No verified blocker found. Deployment QA should still execute the isolated admission/recovery case and verify the deployed SHA/fresh-session admission before resuming FULLTEXT2. This approval does not close the broader campaign or claim the other #27999 changes were backported.
Merge Queue Status
This pull request spent 15 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
Keep the owned varlen area until Grow2 succeeds so allocation rejection cannot orphan the previous native buffer. Preserve the successful copy path and allocation policy. Cover populated and reused-empty destinations, ordinary cleanup and retry after releasing memory pressure. The real MergeOrder execution failure probe now drains native memory after Reset/Free. Port the ownership correction already present in 4.2-dev via #28369.
## 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 #27968. Cherry-picks the Area ownership fix from #28369 (`027194e3ac2a`) to the 4.2.1 hotfix branch. ## What this PR does / why we need it: When bulk appending variable-length Vector data, an allocation or budget rejection can return a nil Area while the previous Area is still allocated. Assigning that result directly to the Vector loses the only cleanup reference. HashJoin can then finish with a nonzero allocation account and suspend later account admission on the same CN. Keep the existing Area until growth succeeds. The conflict was resolved in the 4.2.1 branch's existing `UnionBatch` fast path; allocation policy, error classification, and successful copy behavior are unchanged. The original PR's tests and SQL fixtures are included. A test-only follow-up replaces unsafe pointer inspection with guarded slice access while retaining the zero-length/nonzero-capacity ownership check. Validation on the 4.2.1 base `d8286add2798`, macOS arm64 and Go 1.26.4: - Before the fix, Vector and real HashJoin admission tests reproduced a 4096-byte live allocation and suspended next admission. With the fix, both pass with zero live bytes and usable next admission; successful-growth controls pass. - Full Vector and HashJoin packages passed normally and with race; final adapted regression tests passed normally and with race. - With an isolated single-CN 8 MiB budget, the same HashJoin SQL/physical plan reproduced a 524288-byte account invariant and suspended admission on the base. The fixed candidate returned the ordinary budget error and both existing and new connections returned the expected 16384-row count. - The picked default mo-tester case passed 19/19 twice on the same isolated instance with teardown checked. The picked 8 MiB isolated SQL/result passed 15/15 in mo-tester comparison mode with teardown checked. - Incremental formatting, vet, golangci-lint and repository error checks passed. Molint has no findings in the changed files; its output still includes one pre-existing `checkunsafe` diagnostic in `pkg/container/vector/functionTool_test.go`. The reported customer incident has not yet been tied to this exact SQL path. GitHub CI and validation on the deployed image are pending. --------- Co-authored-by: 和光同尘 <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Related to #27968. Partial backport of #27999; not an automatic issue-closure request.
What this PR does / why we need it:
Backport only the Area ownership fix from upstream commit
17c161a31b47a22e71ca222839143f66717ac365to4.2-dev. A rejectedgrowArea2does not release the old allocation. Receive its result into a temporary slice and publishv.areaonly on success, preserving the owner for normal cleanup.No budget/admission policy, HashJoin cleanup mechanism, public API, MergeTop error classification, or compiler rewrite is changed.
Review fixes
bytes.Clonesnapshots (old bytes and logical row values). Assert row counts and appended values. Explicitly preserve the pre-existingUnionOnecontrol's length-on-error behavior; this PR does not promise atomic append for that API.test/distributed/isolated/area_admission/hashjoin_area.sql/.resultand instructions. On a dedicated single-CN service with the publicprocessLimitationSize=8388608, the same HashJoin query first sees 8,192 64-byte strings, then 8,192 2,048-byte strings. Check its physical HashJoin plan before adding the large batch (EXPLAIN PHYPLANexecutes), reject the later growth, then check COUNT on the original connection and a new session. This configuration-specific fixture is deliberately outside the default BVT cases and must be run separately in QA.Validation
Base:
588295fdabe01fbee49f48107dff98dcc26b6178.Reviewed head:
c7b726705276fca696afa3ce4e9a74f0eca94e77.-count=10: original product hunk restored to base => FAIL (exit 1); repaired => PASS. Failure is real production cleanup residue, not test double-free.mo-cgo-test -v -count=1 -timeout=120s: PASS.-race -count=10 -timeout=240s: PASS.go list,go build,go vetfor both packages, formatting andgit diff --check: PASS.autoReconnect=false): unpatched => exit 1, 11/15 successful with one mismatch and three admission-related abnormal results; repaired => exit 0, 15/15. Red SQL recordsused=524288,owner=1,site=103,live-allocations=1, followed by suspended new-session admission. Green returns the ordinary budget error without an invariant suffix, and both COUNT queries return 16384.The previous head's CI passed; that is not a claim about this new head's CI. Current-head CI and maintainer review remain independent gates. Ready for review is not merge approval.
QA required: yes
Reason: production memory ownership and admission recovery require deployment validation. Run the isolated 8 MiB regression separately, then verify actual deployed SHA and fresh-session admission before restarting the FULLTEXT2 campaign. Local tests do not prove shared-dev recovery or complete FULLTEXT2 acceptance. No shared dev objects were changed for this validation.