Repository navigation
Keep the direct read assertion of 02346_text_index_bug106460 off the trivial count plan - #121282
Conversation
…trivial count plan The `-- materialized` section of this test asserts that once `OPTIMIZE FINAL` has materialized a pending lightweight update, the text-index direct read is available again, by grepping `EXPLAIN actions = 1` for the `__text_index_*` virtual column. That assertion intermittently reads 0 while the data line above it stays correct. Two optimizer passes read the pending-patch state through different predicates. `optimizeDirectReadFromTextIndex` tests patches per selected part, so once the merge has baked the patch in, the rewrite fires and emits the virtual column. `optimizeTrivialCountFromTextIndex` runs after it and declines on the table-level `hasPatchParts()`. `OPTIMIZE FINAL` applies the patch but leaves the patch part itself active until a background cleanup reclaims it; from that moment the count pass applies, takes its fully-materialized branch, replaces the whole `ReadFromMergeTree` step with `ReadFromTextIndexCount` (whose header is a single `count()` aggregate column), and the virtual column leaves the plan even though the direct read did run and did read the index. The property the test was added for holds in both outcomes; only the artifact the assertion looks for disappears. The pass predates the test by about four weeks, so the assertion was written against a plan shape the pass could already remove. The direction matters: the longer the assertion waits, the likelier it fails, so a fix shaped as "wait until the patch is materialized and gone" would convert a rare flake into a permanent failure. Pin the trivial-count pass off for this file, which 24 sibling text-index tests including the canonical direct-read test already do. The assertion then reads 1 whether or not the patch part has been reclaimed, so it stops sampling the cleanup thread, and it keeps asserting the direct read specifically rather than accepting either plan shape. `query_plan_optimize_count_from_text_index` is the surgical term of the pass's three-way conjunction: pinning `query_plan_direct_read_from_text_index` would remove the very artifact being asserted, and `optimize_trivial_count_query` would also disable the unrelated part-metadata trivial count. Forcing the cleanup with `SYSTEM STOP CLEANUP` + `SYSTEM START CLEANUP` makes the failure deterministic: the unpatched file then fails with exactly the CI diff, and the patched file passes. Flipping the pin back reproduces 0; keeping the pin while disabling the direct read still reads 0, so the assertion remains a detector of the defect this test exists for; a misspelled setting name raises `Code: 115` rather than degrading to a silent no-op. The reference file is unchanged, every other asserted value in the file is unaffected, and 50 runs with settings randomization plus 50 without are green.
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold
I re-derived the invariant-carrier sweep before reading the implementation's evidence, and checked Alternatives not taken: accepting either plan artifact stops the assertion saying which read Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20260921-054900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20260921-044300 |
|
Workflow [PR], commit [ce277ee] Summary: ❌
AI ReviewSummaryThis PR disables Final Verdict✅ No findings. I would not post any inline review comments on the current diff. |
CI finish ledger - ce277eeEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only
50 checks succeeded and 131 were skipped on the live attempt; the 164 cancelled runs belong to a superseded attempt on this same head, and Session id: cron:our-pr-ci-monitor:20260921-103829 |
|
Fixing PR for the single failure in the ledger above ( |
|
Does the test still test what it's supposed to test? |
|
Yes. I ran the file from before and after this PR with
Without the fix both versions fail on the same lines, the #106460 symptom: The setting only disables answering a bare The If you prefer, I can move the setting from the file onto that one |
d68bca3
Related: #118496
Related: #111494
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Pin
query_plan_optimize_count_from_text_index = 0in02346_text_index_bug106460so its direct-read assertion no longer depends on whether a background cleanup has already reclaimed the applied patch part.Description
The
-- materializedsection asserts that afterOPTIMIZE FINALmaterializes a pending lightweightupdate, the direct read is available again:
It intermittently reads
0while the data line above stays correct.Root cause. The two passes read the pending-patch state differently.
optimizeDirectReadFromTextIndextests patches per selected part, so after the merge it fires,emitting the
__text_index_*virtual column.optimizeTrivialCountFromTextIndexruns after it anddeclines on the table-level
hasPatchParts().OPTIMIZE FINALapplies the patch but leaves thepatch part active until a background cleanup drops it; the count pass then applies, replaces the
ReadFromMergeTreestep withReadFromTextIndexCount, and the artifact the assertion greps forleaves the plan although the direct read ran. The asserted property still holds. The longer it waits the
likelier it fails, so waiting for the patch to vanish would make the flake permanent.
Change. Pin the trivial-count pass off for this file, as 24 sibling
text_indextests do; theassertion then reads
1in both cleanup states and stops sampling the cleanup thread.Validation. Forcing the cleanup makes it deterministic: the current file fails with exactly
the CI diff (
-1/+0), the patched file passes. Flipping the pin back reproduces0; with thepin kept but the direct read disabled it still reads
0, so the assertion still detects the originaldefect; a misspelled setting raises
Code: 115. The reference is unchanged; 50 randomized and 50non-randomized runs are green.
Left alone: the count pass's patch gate is table-level while the direct read's is per-part, which only
declines an optimization and is that owner's call; and an
EXPLAIN-grepping assertion is onlyas stable as the later passes that may rewrite its step.
Workflow [PR]
Sync PR [sync-upstream/pr/121282]
Version info
26.10.1.1184-master(included in26.10and later)