fix: drop input plan early in CoalescePartitionsExec#22017
Open
Samyak2 wants to merge 2 commits intoapache:mainfrom
Open
fix: drop input plan early in CoalescePartitionsExec#22017Samyak2 wants to merge 2 commits intoapache:mainfrom
CoalescePartitionsExec#22017Samyak2 wants to merge 2 commits intoapache:mainfrom
Conversation
- Fixes apache#22016 - `CoalescePartitionsExec` uses `RecordBatchReceiverStreamBuilder` which was holding to an Arc ref of the input plan, until the stream was done. - Now we drop it early. - The only other usage of `input` was in debug prints, to display the input plan. We now take the display string early, but only when debug logging is enabled. - Added a test that ensures this. Verified that the test fails without the fix.
kumarUjjawal
reviewed
May 5, 2026
| let input_display = if log::log_enabled!(log::Level::Debug) { | ||
| displayable(input.as_ref()).one_line().to_string() | ||
| } else { | ||
| "".to_owned() |
Contributor
There was a problem hiding this comment.
should we use String::new()?
Contributor
There was a problem hiding this comment.
Please don't resolve comments, I like to go back to them during review.
| debug!( | ||
| "Stopping execution: error executing input: {}", | ||
| displayable(input.as_ref()).one_line() | ||
| "Stopping execution: error executing input: {input_display}", |
Contributor
There was a problem hiding this comment.
The Err branch returns before reaching drop(input) at line 356, so input only drops on scope end via the closure. Moving the drop into the Ok arm makes the intent clearer and removes the misleading appearance that drop runs on both paths.
Contributor
Author
There was a problem hiding this comment.
There's a return in this Err branch, so the closure ends immediately and drops input, right? So in both cases, we essentially drop it after this match. Or am I missing something?
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?
CoalescePartitionsExecdelays cancellation of child operators #22016Rationale for this change
CoalescePartitionsExecusesRecordBatchReceiverStreamBuilderwhich was holding to an Arc ref of the input plan, until the stream was done.What changes are included in this PR?
inputwas in debug prints, to display the input plan. We now take the display string early, but only when debug logging is enabled.Are these changes tested?
The reproducer (Samyak2#1) before the fix:
~85ms to cancel repartition tasks.
After fix:
~16ms to cancel repartition tasks.
Are there any user-facing changes?
CPU/memory gets released earlier on cancellation