Repository navigation
Plan-based parallel replicas: keep a read local when a replica cannot build its text index transform - #132916
Conversation
… build its text index transform The text-index rewrite (`processAndOptimizeTextIndexFunctions`) runs before `applyParallelReplicas` and merges the index `preprocessor`/`postprocessor` into the read's filter or PREWHERE. The transform is built under the global context on purpose: its privileges are checked when the index is declared, so a reader without them can still search through the index. A replica, however, rebuilds every function of a shipped plan with `FunctionFactory::get` + `build` under the reader's rights, so `checkAccessOnBuild` threw `FUNCTION_NOT_ALLOWED` there (seen as `02346_text_index_transform_access` failing in the plan-based parallel replicas CI job). The replicas refused this read before ClickHouse#127443 as well, from the function creator. Keep the fragment local when a replica would refuse to build one of its functions: walk every DAG the fragment serializes (`checkQueryPlanActionDAGs`), every function of each node (`allNodeFunctions`, recursing into lambda DAGs), resolve it by the name the plan is serialized with and call `checkAccessOnBuild`. The probe runs on a copy of the context with its own `QueryPrivilegesInfo`, so `system.query_log` privileges do not change. A reader who has the privilege still ships the read. An IN-subquery set needs no extra check: its own fragment goes through the same visitor, and the set plan an outer fragment ships is the unoptimized one (`addPlansForSets` runs after `applyParallelReplicas`), which does not hold the transform. 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; 0 findings; bounded: 1 full pass + 1 fix round + 1 delta recheck). Two points from my own review, both with no code change:
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261119-090100 |
|
cc @ahmadov, could you review this? With plan-based parallel replicas the text-index rewrite merges the index transform, built under the global context, into the shipped filter, and a replica rebuilding it under the reader's rights throws FUNCTION_NOT_ALLOWED; such a fragment is now kept local, like the Top-K and direct-read cases. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261119-082700 |
|
Workflow [PR], commit [9681370] Summary: ❌
AI ReviewSummaryKeeps a plan fragment local when a replica would reject a function injected by a text index transform, while retaining parallel execution for permitted readers. No actionable findings in the current diff or surrounding execution paths. The focused regression test covers preprocessors, lambda postprocessors, an Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes4 object files changed (+21.75 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units1408 translation units recompiled, 41 s compile time in total, 1408 of them have a recent master baseline. |
CI finish ledger - 9681370Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The other CIDB Session id: cron:our-pr-ci-monitor:20261119-123019 |
Related: #128413
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
02346_text_index_transform_accessfails in the newStateless tests (arm_binary, ParallelReplicas, plan-based, s3 storage, parallel)job (CI report): a reader without the privilege for a function of a text indexpreprocessor/postprocessorgetsFUNCTION_NOT_ALLOWEDfrom a replica, while the same read works locally and with query-based parallel replicas.The text-index rewrite merges the index transform into the read's filter before
applyParallelReplicascuts the fragment. The transform is built under the global context on purpose (its privileges are checked when the index is declared), but a replica rebuilds every function of the shipped plan under the reader's rights, socheckAccessOnBuildthrows there.The fragment is now kept local when a replica would refuse to build one of its functions, the same way this file keeps Top-K, direct-read and
mergeTreeProjectionreads local. The probe resolves each function by the name the plan is serialized with and callscheckAccessOnBuildon a copy of the context, so the query's reported privileges do not change. A reader who has the privilege still gets parallel replicas.make_distributed_planships its worker fragments by another path, not changed here.parallel_replicas_plan_basedis experimental, henceNot for changelog. The replicas refused this read before #127443 too, so it is not the cause.Validation: the new test fails on master and passes 50/50 with randomized settings;
02346_text_index_transform_accessunder the plan-based profile withparallel_replicas_local_plan = 0goes from 20/20 FAIL to 20/20 OK; every*_pr_plan_based_*test passes.Workflow [PR]
Sync PR [sync-upstream/pr/132916]