fix: do not close parentSink in Stitcher.finish() success path - #22792
fix: do not close parentSink in Stitcher.finish() success path#22792waterWang wants to merge 1 commit into
Conversation
When the LateMaterialization stage is the root of the query plan (QTF rewrite fires, no downstream ReduceStageExecution), the parentSink is a RowProducingSink whose close() clears every buffered batch. The QueryExecution then reads the result via outputSource().readResult() after the stage's terminal transition, finding an empty batch list and silently returning zero rows. Fixes opensearch-project#22786
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22792 +/- ##
============================================
+ Coverage 71.61% 71.65% +0.03%
- Complexity 77336 77350 +14
============================================
Files 6170 6170
Lines 359671 359671
Branches 52450 52450
============================================
+ Hits 257584 257710 +126
+ Misses 81696 81521 -175
- Partials 20391 20440 +49 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
When the LateMaterialization stage is the root of the query plan (QTF rewrite fires, no downstream ReduceStageExecution), the
parentSinkis aRowProducingSinkwhoseclose()clears every buffered batch. TheQueryExecutionthen reads the result viaoutputSource().readResult()after the stage terminal transition, finding an empty batch list and silently returning zero rows.Root Cause
Stitcher.finish()callsparentSink.close()in its success path after feeding the output. For a non-root LM stage, this signals EOF to the parent stage input sink. For a root LM stage, theparentSinkis the freshRowProducingSinkcreated byStageExecutionBuilder.buildRootExecution(), andRowProducingSink.close()clears every buffered batch — whileQueryExecutionreads the answer after the root stage terminal transition, viaoutputSource().readResult().Fix
Remove the
parentSink.close()call from the success path ofStitcher.finish(). The sink lifecycle is managed by the stage execution, not by the stitcher. TheLateMaterializationStageExecution.onTerminalTransition()already handles cleanup for CANCELLED/FAILED states.Fixes #22786