Skip to content

Fix flaky 02346_text_index_bug108519_qcc_skip_index under randomized statistics - #110260

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-02346-qcc-namecol-auto-statistics
Jul 13, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-02346-qcc-namecol-auto-statistics

Conversation

@groeneai

@groeneai groeneai commented Jul 13, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Follow-up to #108548, which added 02346_text_index_bug108519_qcc_skip_index. The test started failing on master across all build types on 2026-07-13 under CI-randomized settings.

Root cause: the tab_namecol and tab_disj sections use minmax skip indexes on a numeric column n with an out-of-range predicate n = 999. With the randomized materialize_statistics_on_insert = 1 and auto_statistics_types including minmax, a minmax statistic on n is built at insert time and prunes the whole part before the skip-index query condition cache path runs. No QCC entry is written, so the reuse query cannot hit and namecol_reuse_a_reuses_entry flips from 1 to 0.

The randomized-settings diagnosis in the failing CI report confirms the single culprit: materialize_statistics_on_insert True (130/130 fail with it, 184/184 pass without).

Fix: pin auto_statistics_types = '' on both tables so the skip index is the only exclusion mechanism, which is what these sections assert. A table-level MergeTree setting is immune to the session-setting randomizer (the client only injects a setting if it is not already present).

Verified both directions on a debug binary with materialize_statistics_on_insert = 1: the pre-fix test yields namecol_reuse_a_reuses_entry 0 (fail), the fixed test matches the reference exactly (pass). Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=8b9a8c2d3636ea7a077b4e11d250cd28c0cc47c2&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20sequential%29

Version info

  • Merged into: 26.7.1.867 (included in 26.7 and later)

…statistics

The tab_namecol and tab_disj sections use minmax skip indexes on a numeric
column with an out-of-range predicate (n = 999). Under the CI-randomized
materialize_statistics_on_insert = 1 with auto_statistics_types including
minmax, a minmax statistic on n is built at insert and prunes the part before
the skip-index query condition cache path runs. No QCC entry is written, so the
reuse query cannot hit and namecol_reuse_a_reuses_entry flips 1 to 0.

Pin auto_statistics_types = '' on both tables so the skip index is the only
exclusion mechanism, which is what these sections assert. A table-level setting
is immune to the session-setting randomizer (the client only injects a setting
if not already present).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. clickhouse-client --materialize_statistics_on_insert 1 --use_statistics 1 running the tab_namecol section yields namecol_reuse_a_reuses_entry 0 every time.
b Root cause explained? Yes. minmax skip indexes on numeric n with predicate n = 999; randomized materialize_statistics_on_insert = 1 builds a minmax statistic on n that prunes the part before the skip-index QCC path runs, so no QCC entry is written and the reuse hit never happens.
c Fix matches root cause? Yes. auto_statistics_types = '' disables the statistic that shadows the skip index, so the skip index is the only exclusion path, which is what the sections assert.
d Test intent preserved? Yes. The QCC profile-event assertions (populate/miss/reuse) are unchanged; the pin only removes the statistics path that was never part of what the section tests.
e Demonstrated in both directions? Yes. Pre-fix + culprit: namecol_reuse_a_reuses_entry 0 (fail). Fixed + culprit: full test matches the reference (pass).
f Fix is general, not a narrow patch? N/A (flaky-test setting fix, not a code bug). Applied the same pin to the sibling tab_disj section, which has the same numeric-minmax hazard.
g Fix generalizes across inputs? N/A (flaky-test setting fix, not a code bug).
h Backward compatible? N/A (flaky-test setting fix, not a code bug).
i Invariants and contracts preserved? N/A (flaky-test setting fix, not a code bug).

Session id: cron:clickhouse-worker-slot-1:20260713-120400

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @shankar-iyer, test-only follow-up to #108548: the QCC x skip-index regression 02346 went flaky on master under randomized materialize_statistics_on_insert (an auto minmax statistic on the numeric n column pruned the part before the skip-index QCC path, so the reuse hit never fired). Pinned auto_statistics_types = '' on the two numeric-minmax tables so the skip index is the sole exclusion. Both directions verified.

@shankar-iyer shankar-iyer self-assigned this Jul 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [389a832]

Summary: ❌

job_name test_name status info comment
Build (amd_asan_ubsan) ERROR
Build (arm_binary) ERROR
Stateless tests (amd_asan_ubsan, flaky check) ERROR
Stateless tests (amd_asan_ubsan, distributed plan, parallel) ERROR
Stateless tests (amd_asan_ubsan, db disk, distributed plan, sequential, 3/3) ERROR
Stateless tests (arm_binary, sequential) ERROR
Fast test (arm_darwin) DROPPED
Build (arm_darwin) DROPPED
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 1/3) DROPPED
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 2/3) DROPPED

AI Review

Summary

This PR makes 02346_text_index_bug108519_qcc_skip_index deterministic under automatic statistics by explicitly setting auto_statistics_types = '' on the two table definitions whose n = 999 predicates were being satisfied by minmax statistics before the skip-index QCC path ran. I traced the current storage/settings path to confirm that this prevents implicit statistics from being added to those tables at create time, so materialize_statistics_on_insert = 1 can no longer materialize the pruning state that caused the flake.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 13, 2026
@shankar-iyer shankar-iyer added the can be tested Allows running workflows for external contributors label Jul 13, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm force merging this. It's causing hundreds of failures in CI

@Algunenano
Algunenano added this pull request to the merge queue Jul 13, 2026
Merged via the queue into ClickHouse:master with commit 99112f9 Jul 13, 2026
338 of 347 checks passed
alexey-milovidov added a commit that referenced this pull request Jul 13, 2026
Pulls in #110260, the fix for the flaky
test `02346_text_index_bug108519_qcc_skip_index` under randomized
`materialize_statistics_on_insert`, which was the only failing test in
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110179&sha=b2143caac05dd213da79134fa637667a64d5efd5&name_0=PR

Co-Authored-By: Claude Fable 5 <[email protected]>
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 13, 2026
alexey-milovidov added a commit that referenced this pull request Jul 13, 2026
Pull in the merged fix for the flaky test 02346_text_index_bug108519_qcc_skip_index
(#110260), which caused the only real
stateless test failures on the previous CI run of this branch.
alexey-milovidov added a commit to alexey-milovidov/ClickHouse that referenced this pull request Jul 13, 2026
…ause

Pulls in the merged fix from ClickHouse#110260
for the randomized-settings flake in 02346_text_index_bug108519_qcc_skip_index
(failing on 5 stateless shards of the previous CI run for this PR, culprit
setting materialize_statistics_on_insert). No conflicts: master touched none
of this PR's files since the previous merge base.

CI report with the failures: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102308&sha=22618ceb1a3dd7ce53a877452e204eb895de7596
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jul 13, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jul 13, 2026
alexey-milovidov added a commit that referenced this pull request Jul 13, 2026
Pulls in #110260, which fixes the flaky test
02346_text_index_bug108519_qcc_skip_index under randomized
materialize_statistics_on_insert - the cause of 4 of the 5 red checks
on the previous run of this PR:
#109463
pull Bot pushed a commit to stnxo2023/ClickHouse that referenced this pull request Jul 15, 2026
A PR's green CI describes the master of its last run, not of its merge.
PR ClickHouse#108548 merged on 2026-07-13 with CI last run on 07-01; on 07-03
master merged ClickHouse#108511, which added materialize_statistics_on_insert to
the settings randomizer in tests/clickhouse-test. The PR's new test
02346_text_index_bug108519_qcc_skip_index then failed on master whenever
the randomized setting was drawn (~40% of runs) and kept master red for
~7 hours until ClickHouse#110260 pinned auto_statistics_types at the table level.

The merge queue already builds the exact merged state (Build
(amd_binary)) but ran no stateless tests on it. Add "Stateless tests
(amd_binary, flaky check)" to MergeQueueCI: it reruns the PR's
new/changed stateless tests on the merge group state (the PR merged with
the current master), so a semantic conflict with post-CI master changes
bounces the PR from the queue instead of breaking master. The job
self-skips when the PR changes no tests.

Merge-queue runs use a reduced budget (20 iterations / 20 min instead of
50 iterations / 45 min): the PR CI already ran the full flaky check, and
a randomized setting drawn with probability 0.4 per run escapes 20
iterations with probability 0.6^20 ~= 4e-5.

Changed-file detection in merge-queue runs now uses the linked PR's
paginated files list (PR_NUMBER is 0 there, and the commits API caps a
merge commit's file list at 300 entries), and the changed-files fetch
fails closed in merge-queue runs so a GitHub API failure cannot silently
skip the check.

Incident: ClickHouse#108548
Follow-up fix it required: ClickHouse#110260

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-qcc-namecol-auto-statistics

Fix flaky 02346_text_index_bug108519_qcc_skip_index under randomized statistics
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Pulls in ClickHouse#110260, which fixes the flaky test
02346_text_index_bug108519_qcc_skip_index under randomized
materialize_statistics_on_insert - the cause of 4 of the 5 red checks
on the previous run of this PR:
ClickHouse#109463
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
A PR's green CI describes the master of its last run, not of its merge.
PR ClickHouse#108548 merged on 2026-07-13 with CI last run on 07-01; on 07-03
master merged ClickHouse#108511, which added materialize_statistics_on_insert to
the settings randomizer in tests/clickhouse-test. The PR's new test
02346_text_index_bug108519_qcc_skip_index then failed on master whenever
the randomized setting was drawn (~40% of runs) and kept master red for
~7 hours until ClickHouse#110260 pinned auto_statistics_types at the table level.

The merge queue already builds the exact merged state (Build
(amd_binary)) but ran no stateless tests on it. Add "Stateless tests
(amd_binary, flaky check)" to MergeQueueCI: it reruns the PR's
new/changed stateless tests on the merge group state (the PR merged with
the current master), so a semantic conflict with post-CI master changes
bounces the PR from the queue instead of breaking master. The job
self-skips when the PR changes no tests.

Merge-queue runs use a reduced budget (20 iterations / 20 min instead of
50 iterations / 45 min): the PR CI already ran the full flaky check, and
a randomized setting drawn with probability 0.4 per run escapes 20
iterations with probability 0.6^20 ~= 4e-5.

Changed-file detection in merge-queue runs now uses the linked PR's
paginated files list (PR_NUMBER is 0 there, and the commits API caps a
merge commit's file list at 300 entries), and the changed-files fetch
fails closed in merge-queue runs so a GitHub API failure cannot silently
skip the check.

Incident: ClickHouse#108548
Follow-up fix it required: ClickHouse#110260

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-ci 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