fix: refuse memory-limited NestedLoopJoin fallback for left-emission joins with a multi-partition probe side - #24675
Open
ranflarion wants to merge 1 commit into
Open
fix: refuse memory-limited NestedLoopJoin fallback for left-emission joins with a multi-partition probe side#24675ranflarion wants to merge 1 commit into
ranflarion wants to merge 1 commit into
Conversation
…joins with a multi-partition probe side
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
The memory-limited fallback returns wrong rows for join types whose final emission reads the visited-left bitmap (LEFT, LEFT SEMI, LEFT ANTI, LEFT MARK) when the probe side has more than one partition. The fallback rebuilds a per-partition
JoinLeftDataper left chunk withprobe_threads_counter == 1and a per-partition bitmap, so every partition believes it is the last to finish probing and emits its own unmatched set, from a bitmap that only saw its own right rows. Unmatched rows are emitted once per partition, and rows matched only in another partition are emitted as unmatched.Proof, using this file's own
build_table/prepare_join_filter/multi_partitioned_join_collectfixtures (4 right partitions) with a 100-byte memory limit versus unbounded:The existing gate covers only FULL. This extends it to every
need_produce_result_in_finaltype, so an over-budget build side fails withResourcesExhaustedinstead of returning wrong rows. Right-side emission types (RIGHT, RIGHT SEMI, RIGHT ANTI, RIGHT MARK) keep the fallback: each partition owns its right rows exclusively, so their bitmaps are complete per partition. Proper cross-partition coordination of the left bitmap, which would re-enable the fallback for these types, is #22038.What changes are included in this PR?
The
full_join_multi_partitioncondition inNestedLoopJoinExec::executebecomesneed_produce_result_in_final(self.join_type) && right_partition_count > 1, with the comment updated to describe the failure mode.test_overallocationmoves LEFT/LEFT SEMI/LEFT ANTI/LEFT MARK from the succeed-via-fallback group (which collected but never checked the row values) into the must-OOM group alongside FULL.Are these changes tested?
test_overallocationnow asserts theResourcesExhaustedrefusal for all five gated join types with a multi-partition probe side, and still asserts fallback success for Inner and the right-emission types. All 42nested_loop_jointests pass;./dev/rust_lint.shis clean.Are there any user-facing changes?
Left-family nested loop joins with a multi-partition probe side whose build side exceeds the memory budget now fail with
ResourcesExhaustedinstead of returning incorrect results. No API changes.