viirya opened a new pull request, #22038:
URL: https://github.com/apache/datafusion/pull/22038
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases. You can
link an issue to this PR using the GitHub syntax. For example `Closes #123`
indicates that this PR will close issue #123.
-->
- Closes #.
## Rationale for this change
When `target_partitions > 1`, the memory-limited fallback path was building
a per-output-partition `JoinLeftData` with `AtomicUsize::new(1)` for each left
chunk, so each partition emitted unmatched left rows based only on its own
right-side matches. For LEFT, FULL, LEFT SEMI, LEFT ANTI, and LEFT MARK, this
produced wrong results (duplicate unmatched rows; for LEFT SEMI, duplicate
matched rows when multiple right partitions matched the same left row).
## What changes are included in this PR?
This change introduces a plan-level `FallbackCoordinator` that:
- Owns the left spill stream and a single chunk-sized `MemoryReservation`,
- Has the first partition reaching a chunk become its "leader": it loads
the chunk and publishes an `Arc<JoinLeftData>` (with `probe_threads_counter ==
right_partition_count`) into a shared slot,
- Lets every other right partition take an `Arc` clone of the same
`JoinLeftData`, so the visited bitmap and probe-thread counter are shared
exactly as in the single-pass `collect_left_input` path,
- Releases the slot only after the partition that brings the counter to
zero finishes emitting unmatched left rows for the chunk, then notifies waiters
so the next chunk can be loaded.
The per-chunk in-flight fetch and release are driven through `BoxFuture`
fields on `SpillStateActive`, polled across `poll_next` iterations.
The FULL-join multi-partition guard added in #21833 is removed; FULL joins
now use the shared coordination path.
Discussed in
https://github.com/apache/datafusion/pull/21833#discussion_r3172430872 and
https://github.com/apache/datafusion/pull/21833#discussion_r3172496633.
## Are these changes tested?
Added five multi-partition correctness tests. `test_overallocation` is
updated to expect FULL multi-partition to spill (not OOM). Added
multi-partition NLJ spill SLT cases.
## Are there any user-facing changes?
No
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]