Repository navigation
Build the empty JOIN side of the constant-false short-circuit from its child's header - #126204
Conversation
…s child's header Join runtime filters rebuild a JoinStepLogical's input headers with type-only columns (preCalculateKeys). Plan-based parallel replicas optimize the local plan again after that, so tryShortCircuitConstantFalseJoin ran on such a join and built its ReadNothingStep from join->getInputHeaders()[side]: a source step whose output header has null column objects. GraceHashJoin (directly, or after SpillingHashJoin switches to it) dereferences them in TemporaryBlockStreamHolder, and join_use_nulls = 1 fails with NOT_FOUND_COLUMN_IN_BLOCK. Take the header from the replaced subtree's own output, which is what the physical join is built from. In plans optimized only once the two are equal. Closes ClickHouse#126117. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding; bounded: 1 full pass + 1 fix round + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261016-042600 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261016-010800 |
|
cc @vdimir @devcrafter, could you review this? With plan-based parallel replicas the local plan is optimized a second time, after join runtime filters made the join's input headers type-only, so the constant-false JOIN short-circuit built its empty ReadNothing source from a header with no column objects and grace_hash (or a spilling hash join) dereferenced one; the source now takes the replaced subtree's output header. |
|
Workflow [PR], commit [81a2a86] Summary: ✅
AI ReviewSummaryThe PR builds Final VerdictStatus: ✅ Approve |
CI finish ledger - 9df815bEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261016-093007 |
|
@vdimir should be very easy to review |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 8 s compile time in total, 7 of them have a recent master baseline. |
|
I can review it. |
george-larionov
left a comment
There was a problem hiding this comment.
LGTM.
@PedroTadim should this be backported?
|
@groeneai can you confirm if this fix needs to be backported? |
|
Yes, to 26.8, 26.9 and 26.10.
Also, #122128 (where test 04768 comes from) is not on 26.10: the branch was cut before it merged, and no 26.10 backport was created. |
Backport #126204 to 26.10: Build the empty JOIN side of the constant-false short-circuit from its child's header
Backport #126204 to 26.9: Build the empty JOIN side of the constant-false short-circuit from its child's header
Backport #126204 to 26.8: Build the empty JOIN side of the constant-false short-circuit from its child's header
…constant-false short-circuit from its child's header
Closes: #126117
Closes: #126542
Related: #122128
Related: #126542
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A
JOINwhoseONcondition has a constant-false conjunct now works with the experimentalparallel_replicas_plan_basedsetting when the join usesgrace_hash, spills to disk, or runs withjoin_use_nulls = 1, instead of terminating the server or failing withNOT_FOUND_COLUMN_IN_BLOCK.Description
Stress test (amd_debug)aborted the server on04768_parallel_replicas_right_join_null_conjunctwith the randomizedjoin_algorithm = 'grace_hash'(report;Assertion 'px != 0' failedinTemporaryBlockStreamHolder). Minimal query, withparallel_replicas_plan_based = 1:Join runtime filters rebuild the join's input headers with type-only columns (
JoinStepLogical::preCalculateKeys). Plan-based parallel replicas optimize the local plan again after that, so the constant-false short-circuit (#110234) runs on such a join and builds its emptyReadNothingsource from the join's input header: a source whose output columns have no column object.grace_hash(directly, or when a hash join spills) dereferences one inTemporaryBlockStreamHolder; withjoin_use_nulls = 1the query fails withNot found column __table1.b: in block __table1.b String nullptr. #122128 guarded one consumer of the same header (materializeBlockInplace).The empty source now takes the output header of the subtree it replaces, which is what the physical join is built from. Plans that are not optimized twice are unchanged: there the two headers are equal. The same code is on 26.8 and 26.9.
The new test runs the RIGHT JOIN with
hash, a spillingparallel_hash,grace_hashandjoin_use_nulls = 1; on master the spilling andgrace_hashqueries abort the server and thejoin_use_nullsone throws. 20/20 randomized runs abort without the fix, 50/50 pass with it.Independent of #124134, which changes the same function for
WITH TOTALS.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/126204]
Version info
26.11.1.258-master(included in26.11and later)26.10.2.39,26.9.23.14,26.8.32.16