Skip to content

Fix segfault when moving conditions to PREWHERE with the old analyzer on 26.8 - #133157

Merged
clickhouse-gh[bot] merged 1 commit into
26.8from
fix/26.8-prewhere-guard-null-dag-node
Nov 20, 2026
Merged

clickhouse-gh[bot] merged 1 commit into
26.8from
fix/26.8-prewhere-guard-null-dag-node

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

On 26.8, the backport of #131054 (#131109) calls conditionMayThrow on RPNBuilderTreeNode::getDAGNode. That node is null when the AST-based MergeTreeWhereOptimizer::optimize moves the conditions, which happens with the old analyzer when query_plan_optimize_prewhere or query_plan_enable_optimizations is disabled. Any SELECT from a MergeTree table with a movable WHERE condition then segfaults. Master and 26.10+ no longer have the AST path, so this only affects 26.8. This PR skips the check when there is no DAG node, so the behavior is the same as before the backport.

Since 2026-11-14, stress tests on 26.8 fail with this crash (STID 2044-429a), for example https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=133058&sha=028918ffb14f792e6702c2733a65dc2b676a56ad&name_0=BackportPR&name_1=Stress%20test%20%28amd_tsan%29

The new test segfaults with the current 26.8 build from #133058 (build_arm_release).

Related: #131109
Related: #131054
Related: #133058

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

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

Fix a segfault in a SELECT from a MergeTree table with the old analyzer (enable_analyzer = 0) when query_plan_optimize_prewhere or query_plan_enable_optimizations is disabled.

🤖 Generated with Claude Code

Version info

  • Merged into: 26.8.42.15

…ptimization

The backport of #131054 to `26.8` calls `conditionMayThrow` on
`RPNBuilderTreeNode::getDAGNode`, which is null when the conditions are moved to
PREWHERE by the AST-based `MergeTreeWhereOptimizer::optimize` (the old analyzer with
`query_plan_optimize_prewhere` or `query_plan_enable_optimizations` disabled). Master
no longer has that path. Skip the check when there is no DAG node, as before the backport.

Seen in stress tests on `26.8` since 2026-11-14 (STID 2044-429a):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=133058&sha=028918ffb14f792e6702c2733a65dc2b676a56ad&name_0=BackportPR&name_1=Stress%20test%20%28amd_tsan%29
#133058

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [cc78c9e]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Nov 20, 2026
@clickhouse-gh
clickhouse-gh Bot merged commit b4be137 into 26.8 Nov 20, 2026
46 of 47 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the fix/26.8-prewhere-guard-null-dag-node branch November 20, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant