Skip to content

[4.2] fix(frontend): clean partial query result metadata batch - #27500

Merged
XuPeng-SH merged 5 commits into
matrixorigin:4.2-devfrom
aunjgr:backport/27406-4.2
Aug 23, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:4.2-devfrom
aunjgr:backport/27406-4.2

Conversation

@aunjgr

@aunjgr aunjgr commented Aug 23, 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:

issue #27406

What this PR does / why we need it:

Backport #27455 to 4.2-dev.

Keep ownership of the query-result metadata batch inside the builder until every metadata field is appended. Any append error releases all previously populated vectors before returning; a successful return transfers the completed batch to its caller.

The production fix applied cleanly to the newest 4.2-dev tip. Its regression test was placed into the older 4.2 test layout without bringing unrelated main-only tests.

Validation:

  • TestBuildQueryResultMetaBatchCleansPartialBatchOnAppendFailure
  • full pkg/frontend suite

@aunjgr
aunjgr requested a review from XuPeng-SH as a code owner August 23, 2026 11:20
@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 →

@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.

I reviewed exact head daeece841e7fc934c34481b6be20fe941022459f. The production ownership fix is sound, but the new regression test does not assert the behavior it is named for.

TestBuildQueryResultMetaBatchCleansPartialBatchOnAppendFailure only checks err != nil and bat == nil. Those conditions were already true before this fix. defer mpool.DeleteMPool(mp) does not make a leak fail the test: for a normal pool, DeleteMPool logs live bytes but does not turn them into a test failure.

I verified this directly by temporarily removing the production cleanup while keeping the PR test unchanged; the focused test still exited 0. Please assert the ownership oracle before deleting the pool, for example require.Zero(t, mp.CurrNB()). With that assertion added, the exact-head fix passes the focused test for 10 uncached runs and the unfixed implementation fails for the intended retained-allocation reason.

@aunjgr

aunjgr commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Resolved at exact head 096cc4a45 after merging newest 4.2-dev.

I found that mp.CurrNB() alone was not a valid oracle on the PR's original 4.2 base: the partially populated NewVec buffers are Go-heap-backed, so the unfixed implementation still reported zero. I replaced it with a direct cleanup-state oracle without coupling this PR to the separate accounting change:

  • The builder delegates population/error cleanup to a helper that accepts the batch it owns.
  • The test retains that batch and asserts Batch.Clean's terminal state: both Vecs and Attrs are nil after the append failure.
  • With the cleanup call temporarily removed, the exact test fails and shows all 16 vectors still present; with the fix, it passes. The outer builder's error/nil result is also asserted.

Validation: focused test x10, full pkg/frontend, golangci-lint, build, vet, focused race x100 (T=0, N=100), and full frontend race.

@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.

Re-reviewed exact head 096cc4a. The revised regression is mutation-sensitive: removing the builder cleanup leaves all 16 vectors retained and fails the test. Ownership is closed on every partial-error/panic path; successful ownership transfers to saveMeta, whose defer cleans after synchronous serialization. Focused count=10, focused race count=10, full pkg/frontend, diff check, and current CI all pass. Approving.

@mergify mergify Bot added the queued label Aug 23, 2026
@mergify

mergify Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-23 15:08 UTC · Rule: release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-23 15:09 UTC · at 9580291ced7d0a3c7e9b24edaf1cb182b8109bff

This pull request spent 55 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #27500 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.

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

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
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 size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants