Skip to content

Fix flaky prewarm mark cache tests with parallel replicas - #124942

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-prewarm-mark-cache-parallel-replicas
Oct 11, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-prewarm-mark-cache-parallel-replicas

Conversation

@groeneai

@groeneai groeneai commented Oct 9, 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):

The tests 03254_system_prewarm_mark_cache, 03254_prewarm_mark_cache_rmt, 03254_prewarm_mark_cache_columns and 03277_prewarm_cache_2 now sum mark and primary index load counters over the initial query and the parallel replicas queries it starts, instead of reading only the initiator's system.query_log row.

Description

Related: #123825 (same fix for 02417_load_marks_async)
Related: #104924 (enabled 03254_system_prewarm_mark_cache under parallel replicas)

03254_system_prewarm_mark_cache failed in Stateless tests (arm_binary, ParallelReplicas, s3 storage, sequential): job, -1 +0 for LoadedMarksCount > 0 of the first read.

In that lane the table's single segment is read by whichever of the three replicas gets it. In the failing job's query_log the initiator row has 0 loaded marks, while the remote replica's row (is_initial_query = 0, current_database = 'default') has 24. Remote profile events are not merged into the initiator row, and current_database = currentDatabase() drops the replica rows. parallel_replicas_local_plan = 1, already set in the test, does not help: the local plan is used but gets nothing to read. The post-prewarm row has the same blind spot.

The four oracles now sum the counters over all rows whose initial_query_id is one of the test's queries. All replicas share one server's caches and each load is counted once, so the sums are exact (the exact-value references 4 and 2 1 are unchanged), and nothing changes without parallel replicas.

Validation on a master debug binary with the lane's 3-replica config:

  • failpoint slowdown_parallel_replicas_local_plan_read, 20 runs per test: old checks 56/80 FAIL, exactly the runs where the initiator loaded nothing; new checks 80/80 OK, 55 of them such runs;
  • parallel_replicas_local_plan = 0: old 30/30 FAIL, new 30/30 OK;
  • randomized, 50 runs per test: 200/200 with parallel replicas, 200/200 without;
  • removing the SYSTEM PREWARM MARK CACHE, or prewarming before the first read, makes the new check fail 20/20 each.

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

Version info

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

In the ParallelReplicas configuration the single segment of these tests'
tables is read by whichever of the three replicas gets it. When a remote
replica reads it, the mark and primary index load counters land on that
replica's own query_log row (is_initial_query = 0, current_database =
'default'), which the current_database = currentDatabase() filter drops, so
the initiator row shows 0. parallel_replicas_local_plan = 1 does not help:
the local plan is used but gets nothing to read.

Sum the counters over all rows whose initial_query_id is one of the test's
queries, as in 02417_load_marks_async (ClickHouse#123825). All replicas share one
server's caches and each load is counted once, so the exact references are
unchanged, and nothing changes without parallel replicas.

Failing job: 03254_system_prewarm_mark_cache in Stateless tests (arm_binary,
ParallelReplicas, s3 storage, sequential) on PR ClickHouse#124862.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Oct 9, 2026
@groeneai

groeneai commented Oct 9, 2026

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 (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 03272_prewarm_mark_cache_add_column still reads only the initiator row AGREE, not changed Its only row expects 0, so a remote read cannot make it fail; out of scope for this deflake

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-8:20261009-152400

@groeneai

groeneai commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Failpoint slowdown_parallel_replicas_local_plan_read (delays only the local replica's read requests) reddens the old checks in exactly the runs where the initiator loaded no marks (56/80, none outside them); parallel_replicas_local_plan = 0 reddens 03254_prewarm_mark_cache_rmt, 03254_prewarm_mark_cache_columns and 03277_prewarm_cache_2 10/10 each.
b Root cause explained? Yes. A remote replica that reads the segment logs the load counters on its own query_log row (current_database = 'default'), which the current_database = currentDatabase() filter drops; the initiator row then shows 0.
c Fix matches root cause? Yes. The oracles sum the counters over every row of each query (initial_query_id IN (...)); no tag, blacklist entry, disabled parallel replicas or widened bound.
d Test intent preserved / new tests added? Yes. References unchanged; removing the prewarm, or prewarming before the first read, still fails 20/20 each, also when a remote replica does the read.
e Both directions demonstrated? Yes. Same binary and server: old 56/80 and 30/30 FAIL, new 80/80 and 30/30 OK.
f Fix is general across code paths? Yes. All four prewarm tests that assert a load counter on a read were changed; 03272 (expects 0) and the primary-index tests 03273*/03274 (index analysis runs on the coordinator) are not affected.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for types (test-only). Settings: local plan on and off, parallel replicas on and off, 50 randomized runs per test with and without parallel replicas, all green.
h Backward compatible? (maintainer-approved exception only) Yes. Test-only; without parallel replicas each query has one row and the sum equals the old value.
i Invariants and contracts preserved? Yes. Statement order is kept by ORDER BY min(event_time_microseconds); exact-value checks (4, 2 1) stay exact, so nothing is counted twice.

Session id: cron:clickhouse-impl-slot-5:20261009-144600

@clickhouse-gh

clickhouse-gh Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [035559a]

Summary: ✅


AI Review

Summary

This PR deflakes four prewarm-cache stateless tests under ParallelReplicas by selecting the initial query ids from the coordinator rows and then summing the mark / primary-index load counters across every system.query_log row in the same query chain. I re-checked the current diff, the surrounding sibling tests, and the existing PR discussion, and I did not find a correctness, coverage, or metadata problem in the updated assertions.

Final Verdict

✅ No new review findings.

@alexey-milovidov alexey-milovidov self-assigned this Oct 10, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 10, 2026
Merged via the queue into ClickHouse:master with commit 5407406 Oct 11, 2026
163 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 11, 2026
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Oct 17, 2026
In the ParallelReplicas lanes the table's single mark goes to whichever
replica asks the in-order coordinator first. When a remote replica wins,
the FileOpen/S3GetObject counts land in its own query_log row
(is_initial_query = 0, current_database = 'default'), which the
`current_database = currentDatabase()` filter drops, so the check read 0
(seen on PR ClickHouse#111166: FileOpen 0 instead of 6).

Sum the counter over all rows whose initial_query_id is one of the
test's queries, as done for the prewarm mark cache tests in ClickHouse#124942.
Replicas without a range open nothing, so the sums are exact and the
references are unchanged; without parallel replicas each group is the
initiator row alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. 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-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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