Skip to content

Backport #110710 to 26.3: Fix text-index direct-read double-registration over Merge/Distributed - #111094

Merged
CurtizJ merged 4 commits into
26.3from
backport/26.3/110710
Jul 21, 2026
Merged

CurtizJ merged 4 commits into
26.3from
backport/26.3/110710

Conversation

@robot-ch-test-poll2

@robot-ch-test-poll2 robot-ch-test-poll2 commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #110710

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.3.17.61

@robot-ch-test-poll2 robot-ch-test-poll2 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 Jul 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [90b50c9]

Summary: ✅

alexey-milovidov and others added 3 commits July 20, 2026 23:25
… for 26.3

The backported optimization in `optimizeDirectReadFromTextIndex.cpp` uses
`ReadFromMergeTree::getIndexReadTasks`, which exists on master but not on
the 26.3 branch, so all builds failed:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111094&sha=f2e8343e5602f40c6465fd466eea1a33b61a0c6e&name_0=BackportPR
PR: #111094

Add the same read-only accessor to 26.3.

Co-Authored-By: Claude Fable 5 <[email protected]>
26.3 does not have #109188,
which makes `StorageMerge` and `StorageDistributed` opt out of the
`optimize_functions_to_subcolumns` rewrite. When the test runner randomizes
that setting to 1, `mapValues(attributes)` in PREWHERE is rewritten to the
subcolumn `attributes.values`, which `Merge` rejects with `ILLEGAL_PREWHERE`.
Pin the setting to 0 so the predicate keeps the function form that matches
the text-index expression, as in the original repro.

Same fix as on backport/26.4/110710 (PR #111095), where it was verified
against the PR's arm_release binary: the unpinned test fails with
`ILLEGAL_PREWHERE` under `optimize_functions_to_subcolumns = 1`, the pinned
test matches the reference.

Co-Authored-By: Claude Fable 5 <[email protected]>
On 26.3 (unlike master and 26.4+) the direct-read-from-text-index
optimization is additionally gated on `use_skip_indexes_on_data_read`
(see `QueryPlanOptimizationSettings`). The test runner randomizes that
setting, and with 0 the optimization is disabled, so the EXPLAIN
visibility check returned 0 instead of 1:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111094&sha=c0d34f6c3f0541798b82274dadacf4d815a466bd&name_0=BackportPR&name_1=Stateless%20tests%20%28amd_asan%2C%20distributed%20plan%2C%20parallel%2C%201%2F2%29

A session-level SET is not enough on 26.3: it does not reach the plan
optimization of a query explained via SELECT ... FROM (EXPLAIN ...), so
the setting is also pinned in the SETTINGS clause of every query that
needs direct read engaged (the trigger query, both EXPLAIN checks, and
the direct-read-on comparison query). Verified against the CI-built
arm_release 26.3 binary: the unpinned test reproduces the CI diff under
use_skip_indexes_on_data_read=0, the pinned test matches the reference
under all adverse setting combinations.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

The remaining CI red on commit c0d34f6 is addressed in 90b50c9: on 26.3 (unlike master and 26.4+) the direct-read-from-text-index optimization is additionally gated on use_skip_indexes_on_data_read, which the test runner randomizes, so the EXPLAIN visibility check in the 04549 test spuriously returned 0. The setting is now pinned to 1 (a session-level SET alone does not reach the plan optimization of a query explained via SELECT ... FROM (EXPLAIN ...) on 26.3, so it is also pinned in the SETTINGS clause of every query that needs direct read engaged). Verified against the CI-built arm_release 26.3 binary: the unpinned test reproduces the CI diff, the pinned test matches the reference under all adverse setting combinations.

The other two failures in that run are unrelated to this backport:

@CurtizJ
CurtizJ merged commit 73e33a0 into 26.3 Jul 21, 2026
35 checks passed
@CurtizJ
CurtizJ deleted the backport/26.3/110710 branch July 21, 2026 22:12
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
CTE/AN/QP: same text-index predicate in PREWHERE and WHERE, Merge over Distributed -> exc LOGICAL_ERROR.
Effect in the production build a394e92: its upstream test(s) 04549_text_index_prewhere_where_dup_over_merge_distributed fail on it and pass on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/server_triage_PROD263_vs_UP2688.tsv).
Upstream patch unchanged, with its test(s): 04549_text_index_prewhere_where_dup_over_merge_distributed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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