Repository navigation
Fix logical error Logical error: Trying to extract chunk from ChunkBuffer before all inputs are finished in correlated subqueries - #95080
Merged
Conversation
The `ISimpleTransform::prepare` method can call `onFinish` from two different code paths: when the output port finishes and when the input port finishes. This caused `SaveSubqueryResultToBufferTransform::onFinish` to call `chunk_buffer->onInputFinish` multiple times, leading to an underflow of `unfinished_inputs` counter in `ChunkBuffer`. Added a `finished` flag to ensure `onInputFinish` is only called once, and added a `chassert` in `ChunkBuffer::onInputFinish` to catch underflow issues in debug builds. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Contributor
|
Workflow [PR], commit [7232670] Summary: ❌
|
Member
Author
|
The fix itself could be better, let's ask @novikd |
…streams The previous commit added a `finished` flag to prevent double `onFinish` calls, but the root cause was that `addSimpleTransform` creates transforms for main streams plus totals/extremes streams, while `setInputsNumber` was only counting main streams. This caused a mismatch that led to underflow of the `unfinished_inputs` counter. This commit fixes the root cause by using the `StreamType` overload of `addSimpleTransform` to only create transforms for main streams. The totals/extremes streams will pass through unchanged. Note: Correlated subqueries with WITH TOTALS will return NULL for the totals row. This is a known limitation of the common subplan buffering optimization when combined with totals. Co-Authored-By: Claude Opus 4.5 <[email protected]>
The correlated subquery pattern in this test requires the new analyzer (the old analyzer doesn't support referencing outer columns like `t0.c0` in correlated subqueries). Co-Authored-By: Claude Opus 4.5 <[email protected]>
novikd
approved these changes
Jan 26, 2026
Comment on lines
+58
to
+62
| size_t streams = pipeline.getNumStreams(); | ||
| if (pipeline.hasTotals()) | ||
| --streams; | ||
| if (pipeline.hasExtremes()) | ||
| --streams; |
Member
There was a problem hiding this comment.
I just added a correct calculation of the number of inputs.
Member
Author
|
Ok, but now the test fails. |
This reverts commit 6ba1f3c.
1 task
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.
The
ISimpleTransform::preparemethod can callonFinishfrom two different code paths: when the output port finishes and when the input port finishes. This causedSaveSubqueryResultToBufferTransform::onFinishto callchunk_buffer->onInputFinishmultiple times, leading to an underflow ofunfinished_inputscounter inChunkBuffer.Added a
finishedflag to ensureonInputFinishis only called once, and added achassertinChunkBuffer::onInputFinishto catch underflow issues in debug builds.Changelog category (leave one):
See https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=95068&sha=bdb2c3ebf0d614b433e0d2861f7d32951a43ab79&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29&name_1=AST%20fuzzer%20%28amd_debug%29
#95068
Fixes #93832.
Version info
26.2.1.233