Repository navigation
Do not distribute a read that uses direct read from a text index - #116363
Conversation
`query_plan_direct_read_from_text_index` rewrites the text-search functions in a read's `PREWHERE` into `__text_index_*` virtual columns, which only that read's index read tasks materialize. The task map is not serialized, so shipping such a read as a plan fragment fails on the replica: - `Code: 10. DB::Exception: Column '__text_index_idx_str_like_<hash>' not found in table` while the replica deserializes the read step, and - `Code: 49. DB::Exception: Query builder not found for text search query` at execution time when `PREWHERE` and `WHERE` carry different text-search queries. `ReadFromMergeTree::isSerializable` already reports the step as unshippable and `verifyBucketedReadSupported` rejects it for `make_distributed_plan`, but plan-based parallel replicas plants its split marker without consulting either. Keep such a read local in `mergeTreeReadCanBeShipped`, next to the Top-K guard, which exists for the same reason - a synthetic column the replica cannot resolve. The read is then not distributed at all, so `02346_text_index_parallel_replicas` pins the query-based implementation to keep asserting what it was written for. Serializing the index read tasks, so these reads can be distributed again, is left to #116360. Closes: #113664 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [e6a84d8] Summary: ✅
AI ReviewSummaryThis PR keeps Tests
Final Verdict
LLVM Coverage ReportMeasured on commit e6a84d8.
Changed lines: Changed C/C++ lines covered: 4/5 (80.00%) · Uncovered code |
Review feedback: `ReadFromMergeTree::isSerializable` returns `true` unconditionally, so the previous comment was wrong to say it reports a read with index read tasks as unshippable. What actually happens is that `ReadFromMergeTree::serialize` does not carry the task map, and only `supportsBucketedRead` refuses such a read - for a bucketed distributed read, not for an ordinary shipped fragment. Nothing rejected it on this path, which is why the guard is needed here. Comment only. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| -- read from a text index (its index read tasks are not serialized), so it keeps such a read local and | ||
| -- `ParallelReplicasUsedCount` would be 0. Drop this pin once | ||
| -- https://github.com/ClickHouse/ClickHouse/issues/116360 is fixed. | ||
| SET parallel_replicas_plan_based = 0; |
There was a problem hiding this comment.
This pin removes the only stateless coverage of text-index reads under parallel_replicas_plan_based, which is the exact contract this PR is changing. The guard in applyParallelReplicas.cpp looks reasonable, but without a parallel_replicas_plan_based = 1 case that proves the query now stays local instead of throwing, a future change can re-enable fragment shipping and bring back #113664 with no test failure.
We already have the right pattern in tests like 04647_pr_plan_based_final.sql and 04838_pr_plan_based_top_k_filter.sql: keep plan-based mode on, assert the results still match local execution, and pin the shape (EXPLAIN has no ReadFromParallelReplicas, or ProfileEvents['ParallelReplicasUsedCount'] = 0). Please keep this query-based pin only if you also add that focused plan-based regression case here or in a new test.
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, 16 s compile time in total, 7 of them have a recent master baseline. |
…dex guard The merge that brought in the `hasPinnedBlockNumbers` guard placed it between `if (!read.getIndexReadTasks().empty())` and its `return false;`, so the text-index guard ended up guarding the next `if` instead of returning. It only refused to ship a read that had pinned block numbers as well, which made it a no-op for the case it was added for. `clang-tidy` caught this as `readability-misleading-indentation` in `Build (arm_tidy)`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
query_plan_direct_read_from_text_index(defaulttrue) rewrites the text-search functions in a read'sPREWHEREinto synthetic__text_index_<index>_<function>_<hash>virtual columns, which only that read's index read tasks materialize. The task map is not part ofReadFromMergeTree::serialize, so shipping such a read as a plan fragment fails on the replica in two ways:Code: 10. DB::Exception: Column '__text_index_idx_str_like_<hash>' not found in tablewhile the replica deserializes the read step (TCPHandler::receiveQueryPlan→ReadFromMergeTree::deserialize→StorageSnapshot::getSampleBlockForColumns).Code: 49. DB::Exception: Query builder not found for text search queryat execution time whenPREWHEREandWHEREcarry different text-search queries (Text index direct read: LOGICAL_ERROR "Query builder not found for text search query" when PREWHERE and WHERE each use a text-search function under plan-based parallel replicas #113664).Nothing rejected such a read on this path:
ReadFromMergeTree::isSerializableistrueunconditionally, and the only existing refusal -supportsBucketedRead/verifyBucketedReadSupported- applies to a bucketed distributed read (make_distributed_plan), not to an ordinary shipped fragment. This keeps such a read local inmergeTreeReadCanBeShipped, right next to the Top-K guard, which exists for exactly the same reason - a synthetic column the replica cannot resolve.Verified locally against a debug server with
parallel_replicas_plan_based = 1:LOGICAL_ERRORor aborted the debug server before), andParallelReplicasUsedCount = 0confirms the read is kept local;02346_text_index_parallel_replicasno longer throws.Because the read is no longer distributed,
02346_text_index_parallel_replicaswould reportParallelReplicasUsedCount = 0, so it pinsparallel_replicas_plan_based = 0to keep asserting what it was written for. Serializing the index read tasks so these reads can be distributed again - and dropping both the guard and that pin - is tracked in #116360.Closes: #113664
Related: #116360
Related: #112351
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
Column '__text_index_...' not found in tableandQuery builder not found for text search querywhen a query using a text index read withparallel_replicas_plan_basedenabled.Workflow [PR]
Sync PR [sync-upstream/pr/116363]
Version info
26.9.1.761(included in26.9and later)