Skip to content

Make 05355_top_k_dynamic_filter_single_sort_column_ties non-parallel - #127694

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-flaky-05355-top-k-dynamic-filter-no-parallel
Oct 25, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-flaky-05355-top-k-dynamic-filter-no-parallel

Conversation

@groeneai

@groeneai groeneai commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #125122

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

05355_top_k_dynamic_filter_single_sort_column_ties (added in #125122) failed with -cache read 1 / +cache read 0 on master (amd_tsan, s3 storage, parallel, 3/3) and on #127638 (arm_binary, ParallelReplicas, s3 storage, parallel).

The cache read check reruns a query whose entries an earlier query wrote to the server-wide query condition cache. Dropping a MergeTree table without a UUID (in an Ordinary or Memory database) calls Context::clearCaches(), which also empties that cache. In both runs a parallel test did this between the two queries (04498_database_max_tables on master, 01069_database_memory on the PR), so the rerun missed all 3 parts. This is the same cause as #125702.

The test is now no-parallel. Queries and .reference are unchanged.

Validation (debug build): with a Memory-database MergeTree drop between the fill and the rerun, the check fails 5/5 (0 hits, 3 misses), and 5/5 passes without it. Under a concurrent drop loop the unmodified test fails 6/20, always on the cache read or cache entries with ties kept line. With the tag, the runner schedules it only as a sequential test, and it passes 50/50 with randomized settings. The Random settings limits line still applies.


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

Version info

  • Merged into: 26.11.1.780-master (included in 26.11 and later)

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]>
@groeneai

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

Own cold review and an independent second-model review (Gate B) of this head: 0 findings.

Checked: MergeTreeData::dropAllData and MergeTreeData::rename call Context::clearCaches() for a table without a UUID, and that clears the query condition cache; the runner reads Tags: and Random settings limits: from any comment line, so the limits line still applies; only the cache read and cache entries with ties kept checks can fail when the cache is cleared, and both need the tag.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The test's own table, fill and 05355_cached_rerun query with a Memory-database MergeTree create + drop in between: cache read 0 (0 hits, 3 misses) 5/5; without the drop 1 (3 hits, 0 misses) 5/5.
b Root cause explained? Dropping a MergeTree table without a UUID (Ordinary/Memory database) runs Context::clearCaches(), which also empties the query condition cache. A parallel test did that between the fill and the rerun in both CI runs.
c Fix matches root cause? Yes. The check needs server-wide cache state to survive several queries, which only exclusive scheduling guarantees. Assertions and data are unchanged.
d Test intent preserved / new tests added? Yes. Queries and .reference are unchanged. Test-only fix, so no new test.
e Both directions demonstrated? Unmodified test under a concurrent drop loop: 6/20 FAIL, only the cache read / cache entries with ties kept lines; without the loop 20/20 OK. With the tag the runner schedules it only as a sequential test (--no-sequential filters it out): 50/50 OK with randomized settings.
f Fix is general across code paths? Besides this test, 44 of the other 45 tests that read QueryConditionCacheHits are already no-parallel. The remaining one, 05353_..., has no failures in 30 days, so it is not touched.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test scheduling only).
h Backward compatible? (maintainer-approved exception only) N/A (no settings, no product code).
i Invariants and contracts preserved? Yes. The Random settings limits line is byte-identical and still applied: across 50 runs query_plan_max_limit_for_top_k_optimization stayed at 20000 or above, and the two top-K booleans were never 0.

Session id: cron:clickhouse-impl-slot-41:20261024-064200

@clickhouse-gh

clickhouse-gh Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4aad984]

Summary: ✅


AI Review

Summary

Adds long and no-parallel to 05355_top_k_dynamic_filter_single_sort_column_ties, isolating its cache assertions from concurrent cache clearing and exempting it from the flaky check's 180-second runtime threshold. No actionable findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 24, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @davenger, could you review this and add the can be tested label so CI runs? Dropping a MergeTree table without a UUID (Ordinary or Memory database) calls Context::clearCaches(), which empties the server-wide query condition cache, so a parallel test can wipe the entries this test reads between the fill and the rerun; the test is now no-parallel, queries and reference unchanged.

@alexey-milovidov alexey-milovidov self-assigned this Oct 25, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 25, 2026
Merged via the queue into ClickHouse:master with commit 7509f35 Oct 25, 2026
178 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 25, 2026
@clickhouse-gh clickhouse-gh Bot added comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
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-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... 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