Skip to content

Fix flaky test 04839_parallel_replicas_cancel_before_announcement - #122773

Merged
PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-flaky-04839-cancel-before-announcement
Oct 1, 2026
Merged

PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-flaky-04839-cancel-before-announcement

Conversation

@groeneai

@groeneai groeneai commented Sep 28, 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 test 04839_parallel_replicas_cancel_before_announcement now keeps its table on the local disk and pins automatic_parallel_replicas_mode = 0 for its parallel-replicas queries, and checks that those queries actually use parallel replicas.

Description

Related: #114862 (added the test)

Failed on master in Stateless tests (amd_tsan, s3 storage, sequential, 2/2) (report): partial_result_on_first_cancel did_not_wait became 0, the query took 1652 ms against the 1500 ms bound.

Two causes, both in that job's logs:

  • On the s3 lanes the table is on object storage. Opening a part there takes MetadataStorageFromDisk::metadata_mutex shared, and every metadata commit holds it exclusively. A system.metric_log merge committed for ~1.6 s and the query's read waited for it. Commits there took up to 2.6 s, so no bound below the 3 s failpoint delay is safe.
  • The run had drawn automatic_parallel_replicas_mode = 2 (a quarter of randomized runs do), which runs the single-node plan, so it could not have caught the regression the test is for.

The table now uses storage_policy = 'default', and automatic_parallel_replicas_mode = 0 is added to the test's parallel-replicas settings. The test now also checks that all five cancel queries used parallel replicas (ParallelReplicasUsedCount > 0). The 1500 ms bound and the failpoints are unchanged.

Validation (debug build):

  • s3-backed server under concurrent 2000-column inserts: a one-granule read took up to 337 ms on an s3 table (blocked in readMetadata), at most 7 ms on a default-policy table.
  • Forced automatic_parallel_replicas_mode=2: the old test passes 5/5 without parallel replicas, the new one uses them in every timed query.
  • Without the mode pin, a forced mode 2 now fails the test (used_parallel_replicas 0) instead of passing it.
  • With Don't wait for a replica's announcement to cancel it #114862's initiator fix reverted, the new test fails 10/10 randomized and 5/5 in mode 2; the old one passes 5/5 in mode 2.
  • 50/50 randomized runs on a local-disk and on an s3-backed server.

The metadata_mutex contention itself (reported earlier in #41831) is not changed here.


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

Version info

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

groeneai and others added 2 commits September 28, 2026 14:25
The test failed on master in `Stateless tests (amd_tsan, s3 storage,
sequential, 2/2)`: `partial_result_on_first_cancel did_not_wait` became 0
because the timed query took 1652 ms against the 1500 ms bound.

On the s3 lanes the test table lived on the object-storage disk. Opening a
part there takes `MetadataStorageFromDisk::metadata_mutex` shared, and every
metadata commit on that disk (`MetadataStorageFromDiskTransaction::commit`)
holds it exclusively. In the failing job a `system.metric_log` merge with
2184 columns held it for about 1.6 s and the one-granule read waited for it;
commits in the same job took up to 2.6 s, so no bound below the 3 s
`parallel_replicas_delay_announcement` delay is safe. The table now uses
`storage_policy = 'default'`, the local disk, which has no disk-wide
metadata lock. Nothing the test guards is storage-specific.

The failing run had also drawn `automatic_parallel_replicas_mode = 2`
(p = 0.25 in the runner), which only collects statistics and runs the
single-node plan: no follower was contacted, so such a run cannot catch the
regression the test exists for. `automatic_parallel_replicas_mode = 0` is
added to the test's own parallel-replicas settings, which every timed query
uses. A `Random settings limits` clamp is not used, because the runner
applies the mode-2 bundle (client-level `enable_parallel_replicas = 1` and
friends) before the clamp, which would turn every auxiliary query of the
test into a parallel-replicas query while the delay failpoint is enabled.

Validated on a debug build: a one-granule read of an s3 table waits up to
337 ms in `readMetadata` during concurrent 2000-column inserts while the same
read of a `default`-policy table takes at most 7 ms; with a forced client-level
mode 2 the old test runs no parallel replicas and the new one uses them in
every timed query; with the initiator fix of ClickHouse#114862 reverted the new test
fails 10/10 randomized and 5/5 in mode 2, while the old one passes in mode 2;
50/50 randomized runs pass on a local-disk and on an s3-backed server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A timed query that falls back to a single-node read passes every other line
of the test without reaching the cancel path, as the failing run with
`automatic_parallel_replicas_mode = 2` did. Assert that all five cancel
queries have `ParallelReplicasUsedCount > 0`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Sep 28, 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): 1 finding on the first head, 0 on the re-review of the fixed head.

# Sev Finding Verdict Evidence / action
1 ⚠️ Nothing in the test checked that parallel replicas were actually used, so a single-node fallback (as in the failing mode-2 run) would pass every line (04839_parallel_replicas_cancel_before_announcement.sh) AGREE, fixed in this PR New used_parallel_replicas line: all five cancel queries must log ParallelReplicasUsedCount > 0. With the mode pin removed and mode 2 forced, the test now fails on exactly that line instead of passing

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

Session id: cron:clickhouse-review-slot-48:20260928-220700

@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e179228]

Summary: ✅


AI Review

Summary

This PR makes 04839_parallel_replicas_cancel_before_announcement deterministic by moving the test table to storage_policy = 'default', pinning automatic_parallel_replicas_mode = 0 on the parallel-replicas queries, and adding a guard that the timed queries actually enter the parallel-replicas path. I did not find a correctness or coverage regression in the current diff or the surrounding code.

Tests

Not run locally; review is based on code inspection.

Final Verdict

✅ No new review findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 28, 2026
@groeneai
groeneai requested a review from nickitat September 28, 2026 22:38
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 28, 2026
@PedroTadim PedroTadim self-assigned this Oct 1, 2026
@PedroTadim
PedroTadim added this pull request to the merge queue Oct 1, 2026
Merged via the queue into ClickHouse:master with commit 0da3aba Oct 1, 2026
149 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 1, 2026
@clickhouse-gh clickhouse-gh Bot added comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). 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-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding 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