Skip to content

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

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

alexey-milovidov merged 7 commits into
masterfrom
test-pipeline-stuck-sort-overflow

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

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.

Version info

  • Merged into: 26.3.1.453

@clickhouse-gh

clickhouse-gh Bot commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor

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 <[email protected]>
@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 <[email protected]>
@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

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

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
145 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 <[email protected]>
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