Skip to content

Fix flaky test 05407_merge_tree_max_rows_to_use_cache_max_value with parallel replicas - #127290

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05407-parallel-replicas
Oct 22, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05407-parallel-replicas

Conversation

@groeneai

@groeneai groeneai commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #126536

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

05407_merge_tree_max_rows_to_use_cache_max_value (added in #126536) fails in Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel): 3 of its first 25 runs, on master (job) and on two unrelated PRs (#98992, #127263). One of the two rows prints 0.

With parallel replicas, remote replicas can read some or all of the 13 marks. Their UncompressedCacheHits/Misses events are only in their own query_log rows (same initial_query_id, current_database = 'default'). The test read only the initiator's row, which has 0 when the remote replicas did all the reads. The failing job's own query_log shows this: initiator 0 events, replica 13 hits.

The check now sums the events over all QueryFinish rows of each initial query. Without parallel replicas only the initiator's row exists, so nothing changes there. The .reference is unchanged.

Validation on a local three-replica setup: with parallel_replicas_local_plan = 0 the old check failed 10 of 10 runs and the new one passed 10 of 10. In the CI lane's mode with randomized settings the old check failed 15 of 50 runs; the new one passed 50 of 50, and also 50 of 50 without parallel replicas. On a binary built before #126536 the new check still prints 05407_max_value 0, both with and without parallel replicas.

🤖 Generated with Claude Code


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

Version info

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

…parallel replicas

With parallel replicas the replica that asks the coordinator first reads all
13 marks of the part. When that is a remote replica, its UncompressedCacheHits
and UncompressedCacheMisses are logged only in its own query_log row (same
initial_query_id, current_database = 'default'): remote ProfileEvents are
forwarded to the client but are not merged into the initiator's row. The test
read only the initiator's row, so in the ParallelReplicas lane one of the two
rows printed 0 in about 1 of 6 runs.

Sum the events over all QueryFinish rows of each initial query instead. With
no parallel replicas only the initiator's row exists, so the result there is
unchanged, and the parallel replicas lane keeps a real check of the forwarded
merge_tree_max_rows/bytes_to_use_cache values on the reading replica.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 Commit message says the first replica "reads all 13 marks"; in the #127263 job two remote replicas split the reads AGREE, noted-not-blocking Wording only, the mechanism is the same; the PR description says "some or all of the 13 marks"

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

Session id: cron:clickhouse-review-slot-8:20261021-225000

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Three-replica local setup, parallel_replicas_local_plan = 0 (the initiator does not read locally): the old check fails 10 of 10 runs with both rows 0; with the local plan plus the slowdown_parallel_replicas_local_plan_read failpoint, 30 of 30.
b Root cause explained? Remote replicas can read some or all of the 13 marks. Their UncompressedCache* events are logged only in their own query_log rows (same initial_query_id); remote ProfileEvents are not merged into the initiator's row, which is the only row the old check read.
c Fix matches root cause? Yes. The check sums the events over every QueryFinish row of each initial query instead of reading only the initiator's row. No tag or setting pin, so the parallel replicas lane keeps the check.
d Test intent preserved / new tests added? Yes. On a binary built before #126536 the new check still prints 05407_max_value 0 (5 of 5), both without parallel replicas and with every read on a remote replica. Test-only change, no new test.
e Both directions demonstrated? Same binary: old check fails 10/10 (local_plan = 0), 30/30 (failpoint) and 15/50 (CI lane mode, randomized); new check passes 10/10, 30/30 and 50/50, plus 50/50 with the failpoint and 50/50 without parallel replicas.
f Fix is general across code paths? The file has one check. The only other test that reads UncompressedCache* from query_log, 00933_test_fix_extra_seek_on_compressed_cache, is already tagged no-parallel-replicas.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only); both parallel_replicas_local_plan values, with and without parallel replicas, randomized settings.
h Backward compatible? (maintainer-approved exception only) N/A (test-only).
i Invariants and contracts preserved? N/A (test-only); .reference unchanged, one row per label.

Session id: cron:clickhouse-impl-slot-5:20261021-223100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov, could you review this and add the can be tested label so CI runs? With parallel replicas the remote replicas log their UncompressedCache* events only in their own query_log rows, so the check now sums the events over every QueryFinish row of the initial query, the same oracle as in #124942.

@clickhouse-gh

clickhouse-gh Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [907a29c]

Summary: ✅


AI Review

Summary

The test now sums UncompressedCacheHits and UncompressedCacheMisses across the initiator and replica QueryFinish rows selected by initial_query_id, preventing false failures when remote replicas perform the reads. No actionable findings.

Missing context / blind spots
  • ⚠️ The affected parallel-replica CI lane has not completed for head 907a29c9e772b21dfe0317a169ec3fb4f44a94ce. No local ClickHouse binary was available for independent execution; runtime evidence comes from the PR's reported forced-remote, randomized, single-replica, and pre-fix-binary validation.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 21, 2026
@Algunenano Algunenano added the can be tested Allows running workflows for external contributors label Oct 21, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 21, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 22, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 22, 2026
Merged via the queue into ClickHouse:master with commit 79e12c3 Oct 22, 2026
352 of 353 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 22, 2026
@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. 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