Skip to content

Fix flaky test 05304_json_shared_typed_paths_replication_backup: sync replica p2 before reading it - #127914

Merged
Avogar merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05304-sync-replica-p2
Oct 28, 2026
Merged

Avogar merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05304-sync-replica-p2

Conversation

@groeneai

@groeneai groeneai commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #127000

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 the flaky test 05304_json_shared_typed_paths_replication_backup, which read replica p2 before it had fetched the part inserted into p1.

Description

Since #127000 merged, 05304_json_shared_typed_paths_replication_backup has failed in Stateless tests (arm_asan_ubsan, azure, parallel) on 3 unrelated PRs (#120906, #98670, #123968). Each time the four p2 comparisons print 0.

Replica p2 gets rows 0..19 only through an asynchronous fetch of the part inserted into p1. Nothing waits for that fetch: alter_sync = 2 waits for the ALTER_METADATA entry, not for an earlier GET_PART, and the test syncs only p1. In the failing runs the fetch took 4.2 / 7.9 / 13.1 s (system.part_log) during a write stall on the cached_azure disk, so p2 was read with only its own 20 rows. In a passing run the fetch takes ~0.1 s.

The test now runs SYSTEM SYNC REPLICA p2 next to SYSTEM SYNC REPLICA p1, as it already does for r2 in its first section.

Validation on a debug build of master 9a348d8c282: with SYSTEM STOP FETCHES p2 delaying the fetch until after the reads, the unmodified test fails 3/3 with exactly the CI diff. With the fix and the fetch delayed by 10 s, it passes 3/3, and SYSTEM SYNC REPLICA p2 waits ~9.6 s for the fetch. 50/50 randomized runs of the fixed test pass.

🤖 Generated with Claude Code


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

Version info

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

…plication_backup

Replica p2 gets rows 0..19 only through an asynchronous GET_PART of the
part inserted into p1. alter_sync = 2 waits for the ALTER_METADATA entry,
which the replication queue does not order after an earlier GET_PART, and
the test synced only p1. When the fetch took longer than the ~2 s before
the p2 reads (4.2 / 7.9 / 13.1 s in the failing arm_asan_ubsan azure runs,
during a cached_azure write stall), p2 was read with only its own 20 rows
and the four p2 comparisons with the Memory table returned 0.

SYSTEM SYNC REPLICA p2 waits for every queued entry, including that fetch,
the same way the first section already syncs r2 before reading it.

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 cold review of the diff (0 findings).
Both traced SYSTEM SYNC REPLICA (DEFAULT mode) through waitForProcessingQueue and checked every replica the test reads.

# Sev Finding Verdict Evidence / action
- - none - -

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

Session id: cron:clickhouse-review-slot-8:20261027-063500

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SYSTEM STOP FETCHES p2 after creating p2, restarted after the p2 reads: the unmodified test fails 3/3 with exactly the CI diff (the four p2 lines 1 -> 0).
b Root cause explained? p2 gets p1's part only through an asynchronous GET_PART. alter_sync = 2 waits for ALTER_METADATA, not for that fetch, and the test syncs only p1, so a fetch slower than ~2 s (4.2 / 7.9 / 13.1 s in the failing runs) leaves p2 with its own 20 rows when it is read.
c Fix matches root cause? Yes. It adds the missing SYSTEM SYNC REPLICA p2 before p2 is read. No bound, setting, tag or data size changed.
d Test intent preserved / new tests added? Yes. All assertions and the .reference are unchanged; the p2 comparisons still check a fetched part. Test-only fix.
e Both directions demonstrated? Yes. Without the fix: FAIL 3/3. With the fix and the fetch delayed by 10 s: OK 3/3, SYSTEM SYNC REPLICA p2 waited ~9.6 s. 50/50 randomized runs pass.
f Fix is general across code paths? Yes. r2 is already synced before it is read, p1 is synced, the other sections use non-replicated tables, and no other test from #127000 reads a second replica.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test synchronisation fix).
h Backward compatible? (maintainer-approved exception only) N/A (test-only).
i Invariants and contracts preserved? Yes. Every replica compared with the full Memory table has received all parts first.

Session id: cron:clickhouse-impl-slot-5:20261027-062200

@clickhouse-gh

clickhouse-gh Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [edbc6b8]

Summary: ✅


AI Review

Summary

The PR adds SYSTEM SYNC REPLICA p2 before reading the second replica in 05304_json_shared_typed_paths_replication_backup. This waits for the outstanding GET_PART work that the existing synchronization of p1 does not cover, preserving all assertions. No actionable findings. Runtime validation was not repeated locally; the PR documents a delayed-fetch reproduction and repeated passing runs with the fix.

Final Verdict

Status: ✅ Approve.

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

Copy link
Copy Markdown
Collaborator Author

cc @tavplubix, could you review this and add the can be tested label so CI runs? The test read replica p2 without syncing it, so a slow asynchronous GET_PART of the part inserted into p1 (4-13 s on the azure disk) left p2 with only its own rows; alter_sync = 2 waits only for ALTER_METADATA, and the fix adds SYSTEM SYNC REPLICA p2.

@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 27, 2026
@Avogar Avogar self-assigned this Oct 27, 2026
@Avogar Avogar added the can be tested Allows running workflows for external contributors label Oct 27, 2026
@Avogar
Avogar added this pull request to the merge queue Oct 28, 2026
Merged via the queue into ClickHouse:master with commit 1d34e67 Oct 28, 2026
526 of 528 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 28, 2026
@clickhouse-gh clickhouse-gh Bot added comp-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... 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-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... 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