Skip to content

fix(frontend): release query result metadata batch - #27454

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aunjgr:fix/query-result-meta-cleanup-27405
Aug 21, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aunjgr:fix/query-result-meta-cleanup-27405

Conversation

@aunjgr

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

Fixes #27405

What this PR does / why we need it:

Releases the temporary query-result metadata batch after object serialization completes. saveMeta retains ownership of the batch across successful writes and every writer error path; object writing stores serialized buffers, not the input batch.

Tests:

  • Test_saveQueryResultMeta
  • TestReturningQueryResultPublishFailureAccountsAbort
  • full pkg/frontend suite
  • CGo-aware go vet for pkg/frontend

@aunjgr
aunjgr requested a review from XuPeng-SH as a code owner August 21, 2026 10:15
@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.

Reviewed exact head 3f8cb75.

saveMeta is the correct owner of the returned metadata batch. objectWriterV1.Write synchronously serializes vectors into writer-owned buffers, so deferring metaBat.Clean after construction safely covers normal completion plus writer construction, Write, WriteEnd, and panic exits without use-after-free or double cleanup. The companion partial-construction cleanup is handled separately by #27455.

Validation:

  • Test_saveQueryResultMeta under -race, count=5; passed, including subsequent metadata read/dump.
  • full pkg/frontend test suite; passed.
  • git diff --check passed and review worktree is clean.

No blocking correctness or lifecycle issue found.

@mergify

mergify Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-21 16:19 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-08-21 18:19 UTC · at 1e9569e2c2a29ae5a87a8fa5b405509fe85c0d36 · squash

This pull request spent 1 hour 59 minutes 38 seconds in the queue, including 47 minutes 27 seconds running CI.

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

@mergify
mergify Bot merged commit 603f3dd into matrixorigin:main Aug 21, 2026
26 of 27 checks passed
@mergify mergify Bot removed the queued label Aug 21, 2026
mergify Bot pushed a commit that referenced this pull request Aug 23, 2026
Backport #27454 to 4.2-dev.

Release the temporary query-result metadata batch after object serialization completes. The writer stores serialized buffers rather than the input batch, so saveMeta retains ownership through every success and writer-error path and can safely clean it on return.

The source commit applied cleanly to the newest 4.2-dev tip.

Validation:

- full pkg/frontend suite

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Releases the temporary query-result metadata batch after object serialization completes. saveMeta retains ownership of the batch across successful writes and every writer error path; object writing stores serialized buffers, not the input batch.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Releases the temporary query-result metadata batch after object serialization completes. saveMeta retains ownership of the batch across successful writes and every writer error path; object writing stores serialized buffers, not the input batch.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Releases the temporary query-result metadata batch after object serialization completes. saveMeta retains ownership of the batch across successful writes and every writer error path; object writing stores serialized buffers, not the input batch.

Approved by: @XuPeng-SH

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/XS Denotes a PR that changes [1, 9] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: saveMeta never frees the query-result metadata batch, leaking session mpool memory on every saved query

3 participants