Skip to content

fix: release JOIN reset buffers across execution generations - #30106

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
Ariznawlll:codex/join-reset-generation-buffers
Oct 14, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
Ariznawlll:codex/join-reset-generation-buffers

Conversation

@Ariznawlll

@Ariznawlll Ariznawlll commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG

Which issue(s) this PR fixes

Fixes #30105.

What this PR does / why we need it:

Release execution-owned off-heap JoinBatch/result buffers during Reset in HashJoin, LoopJoin, DedupJoin, and IndexJoin. Clear const-set callbacks that capture the previous execution's MPool; the next execution rebuilds them with its current process.

The defect is resource ownership across prepared-pipeline generations. No SQL result error is claimed. The regression tests check that the previous pool has no retained allocation after Reset and that the operator remains usable with the next execution generation.

2026-10-14 base sync and conflict resolution

Merged official main 2ce4e58af6f03b943ee288ffad81012766cf830a and resolved the conflicts in JSON EXPLAIN source/tests.

Main now owns the plugin-based IndexSearchScan EXPLAIN implementation and its payload/algorithm validation. Keep those two files exactly as main, instead of restoring this branch's older manual aliases. Consequently, the PR diff against main contains only the eight JOIN implementation/test files; JSON EXPLAIN is no longer a separate change or merge dependency in this PR.

The main sync also includes the corrected logservice gossip fixture port-allocator call.

Original implementation validation

  • On official main ef502446dc9fd4d31cc8c969d71e9907dc358dfa, each minimal JOIN case reproduced retained allocation 3/3. A 1024-byte VARCHAR left 1048 bytes in the old MPool after Reset.
  • Full package tests for indexjoin, loopjoin, hashjoin, dedupjoin, apply, rightdedupjoin and product passed; the four focused regression tests passed -race -count=20.

Validation after base sync

On merge commit f8f2a6d2e9, macOS arm64, using the repository's native-artifact provenance guard and mo-cgo-test wrapper:

  • All four focused JOIN generation-reset regressions: passed.
  • Full normal-mode suites for hashjoin, loopjoin, dedupjoin and indexjoin: passed.
  • Selected JSON EXPLAIN regressions (TestBuildSQLJSONPlan|TestSQLJSON): passed.
  • pkg/logservice test compilation with -run '^$': passed. This is a compile check, not a runtime suite.
  • git diff --check: passed.

No new race run, full BVT, external test environment, or manual CI workflow was started in this follow-up. Earlier checkout/TLS failures are infrastructure failures, not claimed fixed by this merge. The PR remains draft; remote checks must validate the new head.

@Ariznawlll Ariznawlll changed the title fix(join): release execution-owned buffers on reset fix: release JOIN reset buffers and align JSON EXPLAIN index scans Oct 13, 2026
@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 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: f8f2a6d2e91ccd195319b29ac482a7952de052ab

Review completed. Read the assessment.

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

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

Commit: f8f2a6d2e91ccd195319b29ac482a7952de052ab

Assessment: approve

Reviewed the complete eight-file delta. Reset correctly releases execution-owned buffers and callbacks through existing cleanup owners. Buffer recreation, dedup vector ownership, error cleanup and subsequent Free remain consistent. No actionable defects found.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

Validation:

  • Traced pipeline cleanup and Prepare/Call reuse for HashJoin, LoopJoin, DedupJoin and IndexJoin, including partial initialization and dedup expression-vector restoration.

  • Reviewed all four new allocation regressions and existing reuse, empty-input and failure tests. The new tests check actual retained allocations and callback clearing.

  • The supplied exact-head CI snapshot reports successful Ubuntu unit tests, Linux arm64 SCA, coverage, shared build and both proxy and pessimistic multi-CN BVT suites.

  • git diff --check passed for the assigned base/head. Verified command, clean source fingerprint and exit 0 in checks/1791967317714114314-3.json against diff-check.log.

  • The change removes retained generation allocations while requiring buffer recreation on subsequent executions. Per-row join processing is unchanged; no new synchronization, storage I/O or shared state is introduced.

Limitations:

  • local_validation is empty; no retained author execution receipts or raw CI logs were supplied. No local runtime tests or performance benchmarks were repeated.

  • The new regressions do not directly switch between two MPools. Subsequent execution was assessed through existing reuse tests and buffer/callback reconstruction paths.

  • Issue #30105's full text was absent from the frozen evidence; its resource-ownership contract was assessed from the PR description and source.

@mergify mergify Bot added the queued label Oct 14, 2026
@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-14 08:43 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-14 08:57 UTC · at e74b66f804357fb094cd6d0985e8f495ce2d2540

This pull request spent 14 minutes 2 seconds in the queue, with no time running CI.

Reason

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

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

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

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 944b721 into matrixorigin:main Oct 14, 2026
@mergify mergify Bot added dequeued and removed queued labels Oct 14, 2026
XuPeng-SH pushed a commit that referenced this pull request Oct 15, 2026
## What type of PR is this?

- [x] BUG

## Which issue(s) this PR fixes

Fixes #30118.

## What this PR does / why we need it:

Further exploration found that the original unique INNER JOIN grouping
defect comes from constant-vector selection copies, not just JOIN
projection. `unionT` and `unionBatch` preserve all-row uniform grouping
but drop partial logical-row grouping. This also affects Batch.Clone and
LoopJoin's bulk build projection.

Fix the underlying vector copies: map partial grouping bits through the
selection/offset/flags while keeping uniform grouping's range fast path.
Remove the temporary unique-projection scalar helper and the
now-unnecessary membership scalar guard; retain bulk JOIN projection.

Add Go UT for vector copies, Batch.Clone, LoopJoin scalar/range/actual
operator resume, and unique HashJoin. No BVT or golden changes.

## Original validation (before the 2026-10-14 base sync)

- Frozen official main: `35c8dd5854750ef96f52f9dd298a70acd031d5e4`,
macOS arm64.
- Before fix, with official main's vector/batch/loopjoin code: 18
vector-copy combinations fail their grouping assertions 3/3; 22 controls
pass 3/3. Both Batch.Clone variants and both LoopJoin bulk/operator
variants reproduce 3/3; scalar LoopJoin control passes 3/3. Original
unique INNER JOIN also reproduced 3/3.
- Matrix covers fixed/string/NULL constants, uniform rollup, flat
controls, repeated/out-of-order selections, offsets, sparse/dense/empty
flags, preflighted publication, preserved prefixes, excluded
out-of-range grouping bits, exact values/NULLs, and resource cleanup.
- Focused vector, batch, LoopJoin and HashJoin tests pass `-race
-count=10` after the root fix.
- Containing vector, batch, LoopJoin, HashJoin and Product suites pass 3
rounds locally.
- `make err-check` and `git diff --check` pass.
- Full local license header check: 6240 files checked, 0 invalid headers
(includes uncommitted exploration files, which are not part of this PR).

This proves an internal vector metadata defect. No public SQL
wrong-result, persistence or multi-CN reproduction is claimed.

## 2026-10-14 follow-up

Merged official main `2ce4e58af6f03b943ee288ffad81012766cf830a`. Main
already contains the JSON EXPLAIN compilation repair and updated
logservice port fixtures; this PR no longer waits for #30106 to supply
an EXPLAIN repair. The diff against main remains the six
vector/batch/JOIN implementation and regression-test files.

Validation of merge commit `6c7efa7ee7` on macOS arm64, using the
repository's native-artifact provenance guard and `mo-cgo-test` wrapper:

- Focused grouping tests in vector, batch, HashJoin and LoopJoin:
passed.
- Full normal-mode suites for those four packages: passed.
- `git diff --check`: passed.

The earlier race/repetition evidence above describes the original
implementation validation, not a new race run after this merge. No BVT,
external test environment, or manual CI workflow was started in this
follow-up. The PR remains draft; remote checks must validate the new
head.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
ci — e74b66f8 Deployed Oct 14, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: JOIN operators retain previous execution buffers after Reset

3 participants