Skip to content

Backport #113742 to 26.6: Skip the custom-key parallel replicas read when the requested stage cannot absorb finalized data - #114634

Merged
clickhouse-gh[bot] merged 3 commits into
26.6from
backport/26.6/113742
Aug 15, 2026
Merged

clickhouse-gh[bot] merged 3 commits into
26.6from
backport/26.6/113742

Conversation

@robot-ch-test-poll4

@robot-ch-test-poll4 robot-ch-test-poll4 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #113742

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.6.3.42

…when the requested stage cannot absorb finalized data
@robot-ch-test-poll4 robot-ch-test-poll4 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels Aug 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [c295b46]

Summary: ✅

@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai

Copy link
Copy Markdown
Collaborator

Investigated. It is the #107619 error, but not the shape #114849 fixes, and #114849 cannot apply to this branch.

What the failure is. test_1.tab, a MutatePlainMergeTreeTask on part all_1_10_2_13. Two mutation tasks for the same table share one deferred set, __set_11032835226742075369_16395267460814454131, for WHERE and(in(y, <set>), greater(1000, x)). At 20:08:58.884 the sibling task on all_11_11_0_13 fails while building it: Code: 153 ... Division by zero: while executing 'FUNCTION modulo(2_UInt8, __table1.number)' (ILLEGAL_DIVISION). 0.5s later the surviving task logs Failed to use statistics for part all_1_10_2_12, skipping statistics pruning for this part carrying that same Code 153, then aborts at src/Functions/in.cpp:116 under FilterTransform::doTransform.

Root cause on this branch. The set build is reached from StatisticsPartPruner::checkPartCanMatch -> getKeyConditionForEstimates -> KeyCondition ctor -> extractAtomFromTree -> tryPrepareSetIndexForIn -> buildOrderedSetInplace (src/Storages/MergeTree/KeyCondition.cpp:2768). That whole call sits inside the per-part catch (const Exception &) at src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp:790, which swallows the exception and only logs at debug. On 26.6 buildOrderedSetInplace consumes source unconditionally (build() does auto plan = std::move(source)), so once the subquery throws mid-build the source is gone, the set is never finishInserted, and nothing propagates the error. The main pipeline then reaches FunctionIn with a not-ready set. The swallowing catch is what converts a normal query error into a logical error, so the trigger here is a throwing IN subquery, not shard unavailability.

Why it is not #114849's shape. No remote read is involved: ReadFromRemote, clusterAllReplicas, ALL_CONNECTION_TRIES_FAILED and unavailable_shard each appear 0 times in clickhouse-server.final.log for this run, against 2 hits for Not-ready Set and 30 for MutatePlainMergeTreeTask as controls. #114849 also targets the speculative clone-and-preserve machinery, which does not exist on 26.6: source_preserved, speculative_set and clone() are 0/0/0 in src/Interpreters/PreparedSets.cpp at 2fb90b2 versus 3/8/1 on master. So #114849 does not apply to 26.6 as written, and this red is not evidence about it either way.

Master. The catch at MergeTreeDataSelectExecutor.cpp:858 still swallows checkPartCanMatch the same way on master, so the statistics-pruning entry into a deferred set build looks still reachable there. I could not turn that into an abort locally: a mutation whose IN subquery divides by zero propagates Code 341/153 normally on both a 26.6.3.40 release binary and today's master debug build, with statistics pruning confirmed live by a positive control (Statistics pruning: 1 parts -> 0 parts). The arms agreeing means my repro did not exercise the shared-set race between two concurrent mutation tasks, so I am not claiming master is fixed.

This looks distinct from the #112152 getMinMaxCountProjectionBlock entry point I already have a fix PR for, since the entry point here is statistics pruning. Do you want me to chase the concurrent-mutation repro and fix the statistics-pruning entry point on master, or is that folded into what you are already doing?

@clickhouse-gh
clickhouse-gh Bot merged commit e1122a1 into 26.6 Aug 15, 2026
75 of 77 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.6/113742 branch August 15, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants