Skip to content

Revert "Fix text_index optimization on multiple passes." - #102108

Merged
alexey-milovidov merged 1 commit into
masterfrom
revert-101939-Fix_101913
Apr 8, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
revert-101939-Fix_101913

Conversation

@rschu1ze

@rschu1ze rschu1ze commented Apr 8, 2026 •

Copy link
Copy Markdown
Member

Reverts #101939

CC: @Ergus

Reason: #101939 (comment)

Version info

  • Merged into: 26.4.1.687

@clickhouse-gh

clickhouse-gh Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3becb55]

Summary: ⏳

job_name test_name status info comment
Stateless tests (arm_asan_ubsan, flaky check) failure
02346_text_index_mark_file_compatibility FAIL cidb

AI Review

Summary

This PR reverts the fix from #101939 for text-index direct-read optimization. The revert removes the protection that handled repeated optimization passes and also deletes the regression test added for #101913. High risk of reintroducing a known LOGICAL_ERROR path and losing future regression protection, so this should not merge in current form.

Missing context
  • ⚠️ No CI logs/results were provided in the review input.
  • ⚠️ No rationale in the code diff showing an alternative mitigation for the reverted bugfix.
Findings
  • ❌ Blockers
    • [src/Processors/QueryPlan/Optimizations/optimizeDirectReadFromTextIndex.cpp:288] Revert removes pre-population of existing text-index virtual-column inputs, reintroducing multi-pass DAG duplication risk previously fixed for #101913.
    • Suggested fix: keep the pre-population logic (or equivalent invariant-preserving logic) so repeated optimization passes do not re-add already-present virtual columns.
    • [tests/queries/0_stateless/02346_text_index_bug101913.sql:1] Existing regression test for #101913 is deleted. This removes safety coverage for the exact failure mode the reverted code previously addressed.
    • Suggested fix: keep this test, or replace it with equivalent coverage that reproduces the multi-pass text-index + additional predicate scenario.
  • 💡 Nits
    • PR metadata does not follow .github/PULL_REQUEST_TEMPLATE.md fields (Changelog category, Changelog entry, docs checkbox), so release-note and changelog quality cannot be validated.
Tests
  • ⚠️ Restore regression coverage for the multi-pass text-index direct-read case (hasAllTokens combined with another filter on Merge/MergeTree path) before merge.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ❌ Regression test 02346_text_index_bug101913 is deleted.
Experimental gate ➖
No magic constants ✅
Backward compatibility ⚠️ Revert likely restores previously fixed incorrect behavior (#101913) on valid queries.
SettingsChangesHistory.cpp ➖
PR metadata quality ⚠️ PR body does not follow template fields required for changelog quality checks.
Safe rollout ❌ Reintroduces known failure path without alternative mitigation in this PR.
Compilation time ✅
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Restore invariant-preserving logic preventing duplicate text-index virtual-column re-addition across optimization passes.
    2. Restore or replace regression test coverage for #101913.
    3. Update PR description to match .github/PULL_REQUEST_TEMPLATE.md including proper Changelog category and Changelog entry.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Apr 8, 2026
@@ -287,17 +287,6 @@ class TextIndexDAGReplacer

/// Cache for added input nodes for each virtual column.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ This removes the regression guard for #101913 and likely reintroduces the same multi-pass DAG failure mode (LOGICAL_ERROR on duplicate virtual-column handling).

If this revert is unavoidable, please replace it with a minimal safe fix that preserves the invariant: existing text-index virtual inputs must be detected before adding new ones in later optimization passes. At minimum, keep a regression test that reproduces the multi-pass case and verifies no exception is thrown.

@@ -1,36 +0,0 @@
-- Regression test for https://github.com/ClickHouse/ClickHouse/issues/101913
-- Full-text index direct-read threw LOGICAL_ERROR when multiple filter conditions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ This deletes an existing regression test. Per ClickHouse review policy, tests should not be removed to land behavior changes, especially when reverting a bugfix.

Please keep coverage for #101913 (or replace with an equivalent updated test) so we do not lose protection against future regressions in text-index direct-read optimization.

@rschu1ze
rschu1ze enabled auto-merge April 8, 2026 17:33
@Ergus

Ergus commented Apr 8, 2026

Copy link
Copy Markdown
Member

We don't need to revert the PR.

The issue is actually when the randomized use_skip_indexes_on_data_read = 0 So not in the optimization, but when falling back to brute force.

I suggest to set it to 1 in the test for now and solve the other case in an independent PR.

@rschu1ze

rschu1ze commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

@Ergus Okay, then let's fix push an actual fix asap. A problem with CI is a bleeding wound (not my words) which needs to be resolved urgently.

@rschu1ze rschu1ze closed this Apr 8, 2026
auto-merge was automatically disabled April 8, 2026 17:49

Pull request was closed

@Ergus Ergus reopened this Apr 8, 2026
@Ergus
Ergus enabled auto-merge April 8, 2026 18:13
@Ergus

Ergus commented Apr 8, 2026

Copy link
Copy Markdown
Member

Let's revert and fix the other correctly (with more tests) all together

@rschu1ze

rschu1ze commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

@Ergus While at it, please also remove the reference to Distributed tables (they are difficult to setup) from the test. The problem repro-s also w/o distributed table: https://fiddle.clickhouse.com/8013b753-ba58-4955-99d8-8f01f8ef6509

@Ergus

Ergus commented Apr 8, 2026

Copy link
Copy Markdown
Member

@Ergus While at it, please also remove the reference to Distributed tables (they are difficult to setup) from the test. The problem repro-s also w/o distributed table: https://fiddle.clickhouse.com/8013b753-ba58-4955-99d8-8f01f8ef6509

@rschu1ze

I already got it.

And with your simpler test the flakiness will disappear.

What we exposed with the new test is a different issue.

Root cause: ColumnConst returns empty even when it is not after a deserialization.

So when serialize_query_plan = 1 + use_skip_indexes_on_data_read = 0 We fallback to the brute force functions that contain this check:

if (!column_needles || column_needles->empty())
    return {};

So, no matches at all and that's what we are getting.

@clickhouse-gh

clickhouse-gh Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 83.90% 84.00% +0.10%
Functions 90.90% 90.90% +0.00%
Branches 76.40% 76.50% +0.10%

Changed lines: 100.00% (2/2) | lost baseline coverage: 118 line(s) · Uncovered code

Full report · Diff report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants