Repository navigation
[4.2-dev] Bound wide payload batches in broadcast hash joins - #33242
Conversation
Backport matrixorigin#32917 to the 4.2 hash build and import memory accounting paths. Keep payload batches within the per-allocation limit and resolve retained build rows across variable-size batches. Fixes matrixorigin#32143 Co-authored-by: lin <[email protected]>
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 8353ba7facd549ad0e0bac89cd528677f917b9b2
Assessment: approve
The broadcast hash-build path now splits retained variable-length columns at allocation boundaries and carries logical row positions through probing and right-join finalization. The row directory is allocated only for nonuniform retained batches; the selected-payload checks and continuation state reuse the existing vector, batch, and query-budget owners. I found no actionable correctness or design defect in the reviewed scope.
Model: gpt-6.1-terra / max
Session: 01a212e9-10a4-7203-9194-162fe0e55042 · slot 0 · generation 13
Validation:
-
The assigned private-/tmp and loopback preflight passed; receipt checks/1795615904860139484-4.json records head 8353ba7 and exit 0.
-
Focused Go tests passed for TestHashBuildRetainedVarlenAllocationBoundary, TestHashJoinRetainedVarlenAcrossBatches, TestJoinOutputProbeResume, TestJoinEmptyOutputRowLimit, and TestJoinMapBuildPayloadChecks, including boundary, budget rejection, continuation, reset, residual, and right-finalization subcases. Full output is focused-tests-noindex.log; checks/1795617058184382820-2.json records the command, frozen head, and exit 0.
-
The reused native libraries were checked against all 170 frozen native inputs and their build ledger; native-provenance.log and checks/1795615928349100039-3.json record the result. A cold dependency fetch timed out and an interrupted cache copy caused later setup failures; the affected module was repaired and verified before the successful run.
Limitations:
-
The PR body reports full-scale single-CN MySQL controls, hard-budget/session reuse, related-package tests, and focused race runs; their raw logs were not supplied in local_validation and those runs were not independently repeated here.
-
The reported performance comparison covers the author's stated narrow local workloads and was not independently reproduced.
🚫 Left the queue · pull request dequeued17 min in the queue, with no time running CI. So far
Reason Pull request #33242 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.
To get back in the queue
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
## What type of PR is this? - [x] BUG ## Which issue(s) does this PR fix? Fixes #33246 Follow-up to #32917. The 4.2-dev backport is #33242. ## What changed? Broadcast HashBuild stages input while constructing the map even when the probe needs only keys. Apply the existing byte limit to those temporary batches. Build the ordinal-to-batch directory only for consumers that retain payload. Keep shuffle recovery and dedup rewrite batching on their current paths. Discard the probe's remaining matches when releasing the JoinMap that owns them. This also covers an upstream LIMIT ending a probe before it drains the current group. ## Validation - Both new regression cases failed before the fix. The wide-key build exceeded the allocator limit, and resetting after 11 of 13 wide matches retained two pending selections. Both pass with the fix. - Single CN over MySQL, default per-allocation limit and an 8 GiB query budget. The build side had 8,192 keys of 262,150 bytes each. The client checked every source ID and every key byte on both tables. The key-only LEFT JOIN returned the expected count of 24,556 and the build-column control returned the expected sum of 33,558,528. - Executed one prepared LEFT JOIN four times on the same connection, alternating a one-row LIMIT over duplicate matches and a single matching build key. Both full executions returned 16,384 distinct probe rows with the correct nine matches and NULL-extended rows. - Eight related packages passed with vet. Three repetitions of the focused race tests passed. The MySQL hard-budget regression passed and the incremental linter reported zero issues. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) does this PR fix?
Fixes #32143
Backport of #32917 to
4.2-dev.What changed?
A broadcast hash join could have enough query memory and still fail when the retained values in one variable-length column crossed the MPool single-allocation limit. Packing 8,192 rows into one batch was sufficient to trigger it. The same limit matters when projecting duplicate matches into the output.
Validation
d2bc81d9f0, the scaled MySQL reproducer returned error 20101 for 8,192 values of 4,100 bytes with a 512 MiB query budget (33,585,150-byte allocation limit, 33,587,200 bytes required). Both controls passed. The backport passed all three cases with the same fixture.ef9dac896bused 65,536 probe rows with 64-byte build values. Across two runs per version and 16 timed queries per case, median latency was 8.45 → 8.66 ms for unique keys and 13.07 → 13.44 ms for duplicate keys. All counts and checksums matched. This measures those two local workloads.Follow-up for #33246
This branch includes the two broadcast JOIN fixes from the main counterpart #33250. Key-only builds now use bounded temporary batches. A probe that stops within a duplicate group drops its pending matches when it releases the owning join map.