Skip to content

Add a test for pipeline suck with sort overflow and window functions#98543

Merged
alexey-milovidov merged 7 commits intomasterfrom
test-pipeline-stuck-sort-overflow
Mar 5, 2026
Merged

Add a test for pipeline suck with sort overflow and window functions#98543
alexey-milovidov merged 7 commits intomasterfrom
test-pipeline-stuck-sort-overflow

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

@alexey-milovidov alexey-milovidov commented Mar 2, 2026

Summary

  • Fixes pipeline deadlock when sort_overflow_mode = 'break' is used with window functions
  • Window functions require fully sorted input. When sort_overflow_mode = 'break' was applied to the sorting step used by window functions, LimitsCheckingTransform would call stopReading() early, leaving ScatterByPartitionTransform with data queued for a finished output port — causing a pipeline deadlock
  • The fix overrides sort_overflow_mode to throw for window function sorting in both the new planner (Planner.cpp) and the old InterpreterSelectQuery paths
  • Adds a regression test that verifies the query throws TOO_MANY_ROWS_OR_BYTES instead of getting stuck

Closes #57728

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

  • Fix pipeline deadlock when using sort_overflow_mode = 'break' together with window functions.

#57728

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Mar 2, 2026

Workflow [PR], commit [ce7a010]

Summary:

@clickhouse-gh clickhouse-gh bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Mar 2, 2026
…erflow_mode = 'break'`

The test only needs to verify the query completes without getting stuck,
not check the exact output value.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nickitat nickitat self-assigned this Mar 2, 2026
@alexey-milovidov alexey-milovidov changed the title Add a test for pipeline stuck with sort overflow and window functions Add a test for pipeline suck with sort overflow and window functions Mar 2, 2026
alexey-milovidov and others added 3 commits March 3, 2026 00:41
…ctions

Window functions require fully sorted input data. When `sort_overflow_mode = 'break'`
was applied to the sorting step used by window functions, the `LimitsCheckingTransform`
would call `stopReading()` early, leaving `ScatterByPartitionTransform` with data queued
for a finished output port, causing a pipeline deadlock.

The fix overrides `sort_overflow_mode` to `throw` for window function sorting in both
the new planner and the old `InterpreterSelectQuery` paths. This ensures window function
sorting always completes or throws a clear error, preventing the pipeline from getting stuck.

Closes #57728

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clickhouse-gh clickhouse-gh bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-not-for-changelog This PR should not be mentioned in the changelog labels Mar 3, 2026
Copy link
Copy Markdown
Member Author

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is trivial and good.

@alexey-milovidov alexey-milovidov added this pull request to the merge queue Mar 5, 2026
Merged via the queue into master with commit 63ed02f Mar 5, 2026
149 checks passed
@alexey-milovidov alexey-milovidov deleted the test-pipeline-stuck-sort-overflow branch March 5, 2026 22:28
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 5, 2026
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request Mar 6, 2026
…ctions

Covers both the new analyzer path (Planner.cpp) and the old planner path
(InterpreterSelectQuery::executeWindow) for the fix in ClickHouse#98543.

Window functions require fully sorted input. When sort_overflow_mode = 'break'
is set, LimitsCheckingTransform stops reading early, leaving
ScatterByPartitionTransform with data queued for a finished output port,
causing a pipeline deadlock. The fix overrides sort_overflow_mode to 'throw'
for window function sorting in both planner paths.

The PR's original test covered only the new analyzer path (enable_analyzer = 1
by default). This test adds the enable_analyzer = 0 variant to ensure
InterpreterSelectQuery::executeWindow is also covered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request Mar 6, 2026
…s_to_sort test

PR ClickHouse#98543 fixed a pipeline deadlock when sort_overflow_mode = 'break' is used with
window functions by overriding it to 'throw' in both Planner.cpp (new analyzer) and
InterpreterSelectQuery.cpp (old planner). Its test only covered the new analyzer path.

Adds both paths to the existing 01131_max_rows_to_sort test which already covers
sort_overflow_mode behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request Mar 6, 2026
…ctions

Covers both the new analyzer path (Planner.cpp) and the old planner path
(InterpreterSelectQuery::executeWindow) for the fix in ClickHouse#98543.

Window functions require fully sorted input. When sort_overflow_mode = 'break'
is set, LimitsCheckingTransform stops reading early, leaving
ScatterByPartitionTransform with data queued for a finished output port,
causing a pipeline deadlock. The fix overrides sort_overflow_mode to 'throw'
for window function sorting in both planner paths.

The PR's original test covered only the new analyzer path (enable_analyzer = 1
by default). This test adds the enable_analyzer = 0 variant to ensure
InterpreterSelectQuery::executeWindow is also covered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pipeline suck

3 participants