fix: bound RepartitionExec channel memory with a byte-budget gate#22092
Closed
JanKaul wants to merge 3 commits into
Closed
fix: bound RepartitionExec channel memory with a byte-budget gate#22092JanKaul wants to merge 3 commits into
JanKaul wants to merge 3 commits into
Conversation
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
Contributor
|
The current behavior of RepartitionExec is required to prevent deadlock in certain cases (like repartitioned Merge). I haven't looked at the code in this PR, but given the description I worry that this will potentially cause new deadlocks I left some more detailed comments here |
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?
Closes #22090.
Rationale for this change
See #22090 — today's "all-channels-non-empty" gate doesn't catch the case where one consumer lags behind a balanced producer. The slow channel grows linearly per input batch.
What changes are included in this PR?
datafusion.execution.repartition_buffer_size_bytes(default 100 MiB).distributor_channels.rs: gate predicate becomesempty_channels == 0 || buffered_bytes >= max_buffered_bytes. Items are stored as(T, usize)so receivers refund bytes on pop. Overdraw escape: an empty channel always accepts a push (a single oversize batch can't head-of-line block its consumer). TheMutex<Option<Vec<Waker>>>double-state is collapsed toMutex<Vec<Waker>>with the counters as the single source of truth.mod.rs: plumbs the config throughchannels/partition_aware_channels; passes batch size at the data-path send and0for spill-marker / sentinel sends.Are these changes tested?
Yes. 21
distributor_channelsunit tests and 48repartitiontests pass.Are there any user-facing changes?
One new config option; otherwise transparent. Default value caps in-memory repartition buffering at 100 MiB — workloads that rely on the previous unbounded buffering may want to set it higher.