Skip to content

[4.2.1 hotfix] fix(vector): preserve Area on admission failure - #32138

Merged
XuPeng-SH merged 2 commits into
release/v4.2.1-hotfix-20261026from
codex/fix-421-vector-area-admission-20261104
Nov 4, 2026
Merged

XuPeng-SH merged 2 commits into
release/v4.2.1-hotfix-20261026from
codex/fix-421-vector-area-admission-20261104

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:

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.

VioletQwQ-0 and others added 2 commits November 4, 2026 11:49
Backport only the Area ownership fix from upstream commit `17c161a31b47a22e71ca222839143f66717ac365` to `4.2-dev`. A rejected `growArea2` does not release the old allocation. Receive its result into a temporary slice and publish `v.area` only 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.

- Separate the retained Area slice (ownership/last-resort cleanup) from `bytes.Clone` snapshots (old bytes and logical row values). Assert row counts and appended values. Explicitly preserve the pre-existing `UnionOne` control's length-on-error behavior; this PR does not promise atomic append for that API.
- Check production account/live-allocation and HashJoin budget usage before any test-only orphan reclamation. Zero-length/non-zero-capacity reused Areas retain ownership.
- Widen the ordinary large-LIMIT fixture above the 23-byte inline threshold. It is explicitly success-path coverage, not evidence of budget-denial cleanup or an unbackported compiler rewrite.
- Add `test/distributed/isolated/area_admission/hashjoin_area.sql/.result` and instructions. On a dedicated single-CN service with the public `processLimitationSize=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 PHYPLAN` executes), 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.

Base: `588295fdabe01fbee49f48107dff98dcc26b6178`.
Reviewed head: `c7b726705276fca696afa3ce4e9a74f0eca94e77`.

- Same final Vector/HashJoin targeted regressions, `-count=10`: original product hunk restored to base => FAIL (exit 1); repaired => PASS. Failure is real production cleanup residue, not test double-free.
- Two complete packages with controlled `mo-cgo-test -v -count=1 -timeout=120s`: PASS.
- Targeted `-race -count=10 -timeout=240s`: PASS.
- `go list`, `go build`, `go vet` for both packages, formatting and `git diff --check`: PASS.
- Official mo-tester comparison mode, isolated SQL, identical fixture/config (`autoReconnect=false`): unpatched => exit 1, 11/15 successful with one mismatch and three admission-related abnormal results; repaired => exit 0, 15/15. Red SQL records `used=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.
- Official mo-tester comparison mode, widened normal large-LIMIT case: exit 0, 19/19.
- Exact-content semantic preflight: PASS. Product executables differ only by the Area ownership hunk (test/doc-only follow-up changes do not enter the service binary).

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.

Approved by: @XuPeng-SH

(cherry picked from commit 027194e)
Preserve the zero-length and nonzero-capacity ownership checks without importing unsafe in the cherry-picked regression tests.
@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner November 4, 2026 04:13
@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/test-ci labels Nov 4, 2026
@mergify

mergify Bot commented Nov 4, 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 Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: eb8255ee7d085174d89c1ae21c8eb760d3435358

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

Assessment: approve

The fix preserves Area ownership when growth fails and follows existing grow/free conventions. Successful-copy behavior is unchanged. No actionable defects remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed all eight changed files, three discussion entries, linked issue context and allocation/HashJoin cleanup consumers.

  • Accepted author-reported normal/race package results, final regressions and baseline/candidate SQL comparisons for this narrow ownership repair.

  • Static audit passed: patch identity, Go formatting, discussion coverage, fixture mappings and independent SQL-result arithmetic. Receipt checks/1793766158814184534-3.json matches static-audit.log.

Limitations:

  • No fresh local Go/race or SQL execution; raw author validation logs were unavailable.

  • Product CI results, deployed-image validation and customer-incident attribution remain unverified.

@XuPeng-SH
XuPeng-SH merged commit 15b1983 into release/v4.2.1-hotfix-20261026 Nov 4, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/fix-421-vector-area-admission-20261104 branch November 4, 2026 04:58
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/test-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants