Skip to content

Fix flaky test 05258_query_condition_cache_prewhere_attribution - #125702

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05258-qcc-no-parallel
Oct 15, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05258-qcc-no-parallel

Conversation

@groeneai

@groeneai groeneai commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122380

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):

Fix flaky test 05258_query_condition_cache_prewhere_attribution.

Description

05258_query_condition_cache_prewhere_attribution asserts that the second query of each pair hits the query condition cache entry the first one wrote. In parallel stateless jobs one _2 row sometimes flips from 1 1 to 0 0 or 1 0, for example this run.

Dropping or renaming a MergeTree table that has no UUID (a table in an Ordinary or Memory database) calls Context::clearCaches(), which also clears the server-wide query condition cache. When a parallel test does that between the two queries of a pair, the second query finds no entry (0 0) or a partial one (1 0). In the run above, 04628_system_replicas_dots_in_names dropped an Ordinary table while qcc_rf_1 was running.

The test is now no-parallel, like the other tests that rely on query condition cache hits across queries. Its queries and .reference are unchanged.

Validation, local debug build: dropping a table in an Ordinary database empties the cache (2 -> 0 entries, Atomic: 2 -> 2). The unmodified test fails 3/20 with the CI signature while another client creates and drops tables in an Ordinary database, and passes 20/20 without it. The tagged test runs in the sequential group and passes 50/50 with randomized settings, plus 10/10 each with the AsyncInsert and ParallelReplicas profiles.

The query condition cache clear in Context::clearCaches() looks redundant, since the cache never stores entries of tables without a UUID, but removing it is a product change and is not part of this PR.


Workflow [PR]
Sync PR [sync-upstream/pr/125702]

Version info

  • Merged into: 26.10.1.2444-master (included in 26.10 and later)

The test asserts that the second query of each pair hits the query
condition cache entry the first one wrote. Dropping or renaming a
MergeTree table without a UUID (Ordinary or Memory database) calls
Context::clearCaches(), which clears the server-wide query condition
cache, so a parallel test doing that between the two queries flips a
`_2` row to `0 0` (entry gone) or `1 0` (partial entry). Seen on
PR 124345, where 04628_system_replicas_dots_in_names dropped an Ordinary
table while qcc_rf_1 was running.

Tag the test no-parallel, as the other tests relying on cross-query
cache hits are. The queries and the reference are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet labels Oct 13, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review of the same tree (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 The tag isolates every clear another test triggers; a clear from a server background job would not be covered by it. AGREE, noted, not blocking No such background source exists today: the cache is cleared only by SYSTEM DROP/CLEAR QUERY CONDITION CACHE (every test that executes it is no-parallel) and by Context::clearCaches() on a DROP/RENAME of a table without a UUID (MergeTreeData.cpp), both test-driven. No diff change.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-9:20261013-221000

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. One server, two clients: after qcc_X_1, a second client creates and drops a MergeTree table in an Ordinary database; qcc_X_2 then reads 0 0 (20000 rows) every time, while the same pair with an Atomic database reads 1 1 (384 rows).
b Root cause explained? Yes. MergeTreeData::dropAllData / rename call Context::clearCaches() for a table without a UUID (Ordinary / Memory databases), which clears the server-wide query condition cache. A parallel test doing this between the two queries of a pair leaves the second query with no entry (0 0) or a partial one (1 0).
c Fix matches root cause? Yes. The test depends on server-global state that other tests may legitimately clear; no-parallel removes that concurrency. The assertions are unchanged.
d Test intent preserved / new tests added? Yes. Queries and .reference unchanged, so every cross-query hit and prune assertion still runs. Test-only change.
e Both directions demonstrated? Yes. Unmodified test with a concurrent Ordinary-database create/drop loop: 3/20 FAIL, each a single _2 row flipped to 0 0 or 1 0; 20/20 OK without the loop. Tagged: the runner reports 4 parallel tests and 1 sequential tests with four clearing neighbours, 10/10 OK.
f Fix is general across code paths? Yes. It is the only parallel-eligible test asserting query condition cache hits across queries; the others already carry no-parallel.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (scheduling tag). 50/50 with randomized settings, 10/10 with the AsyncInsert profile, 10/10 with the ParallelReplicas profile.
h Backward compatible? (maintainer-approved exception only) Yes. No setting, format or behaviour change.
i Invariants and contracts preserved? Yes. In the sequential phase only this test runs, and it drops only tables of an Atomic database, which do not clear the cache.

Session id: cron:clickhouse-impl-slot-7:20261013-213600

@clickhouse-gh

clickhouse-gh Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [dfbe3ce]

Summary: ✅


AI Review

Summary

PR #125702 adds no-parallel to 05258_query_condition_cache_prewhere_attribution, preventing concurrent tests from clearing the server-wide query condition cache between paired queries. The restriction addresses the reported cache-hit flakiness while preserving all queries and expected results. No actionable findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 13, 2026
@groeneai
groeneai requested a review from fm4v October 13, 2026 22:39
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 13, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 15, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 15, 2026
Merged via the queue into ClickHouse:master with commit 61a00a8 Oct 15, 2026
176 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 15, 2026
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-ClickHouse__ClickHouse that referenced this pull request Oct 26, 2026
The `cache read` and `cache entries with ties kept` checks rerun queries
whose entries earlier queries of the test wrote to the server-wide query
condition cache. Dropping or renaming a MergeTree table without a UUID
(in an Ordinary or Memory database) calls `Context::clearCaches()`, which
also empties that cache. In both CI failures a parallel test did that
between the fill and the rerun (04498_database_max_tables on master,
01069_database_memory on ClickHouse#127638), so the rerun missed all 3 parts and
printed `cache read 0`.

Run the test only in the sequential job flavors, as done for 05258 in
ClickHouse#125702. Queries and the reference are unchanged; the Random settings
limits line is kept byte-identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Nov 8, 2026
…equentially

The cache arm compares SelectedMarks of two identical queries: the first one
writes a query condition cache entry for the PREWHERE
`and(__topKFilter(s), notEmpty(s))`, the second one must read it and select
fewer marks. The query condition cache is server-wide. In the failing
`Stateless tests (arm_binary, parallel)` run on PR ClickHouse#129954, the parallel test
05213_timeseries_metric_families_target dropped an inner MergeTree table of a
TimeSeries table in an Ordinary database between the two queries.
MergeTreeData::dropAllData() calls Context::clearCaches() for a table without
a UUID, which also clears the query condition cache, so the second query read
all 100 marks again and the arm printed 0 instead of 1.

Tag the test no-parallel, like 05316 (ClickHouse#125152) and 05258 (ClickHouse#125702), which
failed the same way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. and removed comp-testing Test content only (no production code). labels Nov 22, 2026
thevar1able pushed a commit to actueleai/ClickHouse that referenced this pull request Nov 24, 2026
…qcc-no-parallel"

This reverts commit 61a00a8, reversing
changes made to ce42026.

Co-Authored-By: Claude Opus 5.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 comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet 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.

3 participants