Skip to content

Fix flaky test_replicated_database_and_unavailable_s3 (digest substring match) - #106571

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix/delta-replicated-db-digest-substring-flaky
Jun 8, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix/delta-replicated-db-digest-substring-flaky

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

The integration test test_storage_delta::test_replicated_database_and_unavailable_s3 set the digest znode of a Replicated database replica to the sentinel value 123456, then after restarting node2 asserted the digest had been recomputed by checking that "123456" no longer appeared anywhere in the full dump of all child znodes (SELECT * FROM system.zookeeper WHERE path = ...).

The recomputed digest is a 64-bit hash; its decimal representation can incidentally contain 123456 as a substring (observed value 9101234564970589296), making the substring check fail spuriously.

The fix queries the digest child value specifically and compares it exactly, so the assertions depend only on the digest value rather than on the textual layout of the entire znode dump.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106423&sha=c63e3b252e8a6bd504220f99031f9ba16a95ce09&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%204%2F4%29
Related: #106423

Changelog category (leave one):

  • CI Fix or improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not for changelog (changelog entry is not required).

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

…st exactly

The test set the `digest` znode to the sentinel value `123456` and, after a
`node2` restart, asserted that the digest had been recomputed by checking that
`"123456"` no longer appeared in the full dump of all child znodes under the
replica path (`SELECT * FROM system.zookeeper WHERE path = ...`).

The recomputed digest is a 64-bit hash; its decimal representation can
incidentally contain `123456` as a substring (observed `9101234564970589296`),
which made the substring check fail spuriously.

Query the `digest` child value specifically and compare it exactly, so the
assertions depend only on the digest value and not on the textual layout of the
whole znode dump.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106423&sha=c63e3b252e8a6bd504220f99031f9ba16a95ce09&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%204%2F4%29

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [18dce43]

Summary: ✅


AI Review

Summary

This PR fixes a flaky assertion in test_replicated_database_and_unavailable_s3 by reading the digest child from system.zookeeper and comparing the value exactly, instead of substring-matching a dump of sibling znodes. I reviewed the current diff, prior PR discussion, PR metadata, and the latest CI report; I found no actionable correctness, safety, or test-quality issues.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 5, 2026
@davenger davenger self-assigned this Jun 5, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Merged master (was 371 commits behind, conflict-free).

The sole CI failure, test_hedged_requests/test.py::test_stuck_replica, is unrelated to this PR (which only touches test_storage_delta). It fails with pause_container('node_1') did not become observably effective within 90.0s — a docker-pause harness issue in _wait_for_pause_effective (helpers/cluster.py:4484). CIDB shows the same failure recurring across many unrelated PRs over the past month (#105010, #106311, #103229, #105056, #104830, #103404, #101354), so it is a pre-existing flaky infrastructure problem, not a regression.

@groeneai, please investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106571&sha=1913277aa988b1091a42f3ffca676dea2b0703eb&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%201%2F6%29 and provide a fix in a separate PR. If a fix is already in progress, link it here.

@clickhouse-gh

clickhouse-gh Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.50% 84.60% +0.10%
Functions 92.30% 92.30% +0.00%
Branches 77.20% 77.20% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 499 line(s), 38 function(s) across 144 file(s) · Details

Top files
  • src/Functions/FunctionShowCertificate.cpp: 38 line(s), 4 function(s)
  • src/Storages/ObjectStorage/DataLakes/Iceberg/Utils.cpp: 31 line(s)
  • src/Storages/StorageReplicatedMergeTree.cpp: 24 line(s), 2 function(s)
  • src/Storages/ObjectStorage/DataLakes/Iceberg/Mutations.cpp: 13 line(s), 1 function(s)
  • src/Common/ZooKeeper/ZooKeeper.cpp: 11 line(s)

Full report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 8, 2026
Merged via the queue into master with commit 87de2fa Jun 8, 2026
166 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix/delta-replicated-db-digest-substring-flaky branch June 8, 2026 01:24
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 8, 2026
@groeneai

groeneai commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

@alexey-milovidov filed the separate fix at #106695.

CIDB cross-PR (last 30 days, all on Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/6)) shows 9 unrelated PRs hit by the same chronic flake, all with the identical signature:

pause_container('node_1') did not become observably effective within 90.0s
... still succeed after ~890 probe iterations; last outcome: server replied (4 bytes)

That server replied (4 bytes) outcome means the probe is receiving live ClickHouse exception packets from node_1 for the full 90s budget, which means docker compose pause returned success while the cgroup freezer never actually froze the user-space tasks. The existing SIGSTOP fallback in ClickHouseCluster.pause_container only fires when docker compose pause itself raises, not when it lies about success.

Switched the test to cluster.pause_container_using_signal (already used by test_postgresql_replica_database_engine), which uses SIGSTOP/SIGCONT and bypasses the cgroup freezer.

Hits in the 30-day window: #103404, #106311, #105010, #105056, #104830, #106025, #100391, #106571, #103229.

@groeneai

groeneai commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Update on the test_stuck_replica fix at #106695: the bot caught a real issue with the v1 fix and I have pushed a follow-up commit (606d8775c31).

The v1 was switching the test to cluster.pause_container_using_signal. The bot correctly flagged that docker compose kill --signal=SIGSTOP <container> signals PID 1 of the container, which is the bash entrypoint wrapper from tests/integration/integration-tests-entrypoint.sh ("$@" &; wait $PID), not clickhouse server. Bash does not propagate uncatchable stop signals, so v1 would have converted the flake into a deterministic 90s timeout.

The follow-up commit fixes the helper itself: _pause_container_using_signal and _unpause_container_using_signal now use docker exec ... pkill -STOP clickhouse / pkill -CONT clickhouse to signal the actual server process directly, with a docker compose kill fallback for non-ClickHouse containers. This is the same pkill clickhouse primitive stop_clickhouse already uses successfully for graceful shutdown.

PR #106695 still open, 2 commits, awaiting CI rerun.

Maoyao233 pushed a commit to Maoyao233/ClickHouse that referenced this pull request Jun 8, 2026
`test_hedged_requests/test.py::test_stuck_replica` is chronically flaky
on heavily overcommitted ASan/UBSan integration shards. The failure shape
in CIDB is identical across 9 unrelated PRs in the past 30 days:

    pause_container('node_1') did not become observably effective within
    90.0s ... still succeed after ~890 probe iterations; last outcome:
    server replied (4 bytes)

The probe in `_wait_for_pause_effective` keeps receiving live ClickHouse
exception packets from `node_1` for the entire 90s budget, which proves
that `docker compose pause` returned success while the cgroup freezer
never actually froze the user-space tasks. The existing SIGSTOP fallback
in `ClickHouseCluster.pause_container` only fires when `docker compose
pause` raises an exception, not when it lies about success, so the
escalation path was never taken.

Switch this test to `cluster.pause_container_using_signal`, which uses
`SIGSTOP`/`SIGCONT` from the start. A signal cannot be silently lost the
way the cgroup freezer can, so the pause becomes observable on the very
first probe iteration. Same helper is already used by
`test_postgresql_replica_database_engine` for the same reason.

The change is local to one call site. The chronic flake hit
`Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/6)` in the
following PRs (CIDB, last 30 days): ClickHouse#103404, ClickHouse#106311, ClickHouse#105010, ClickHouse#105056,
ClickHouse#104830, ClickHouse#106025, ClickHouse#100391, ClickHouse#106571, ClickHouse#103229. All show the same
`server replied (4 bytes)` outcome, distinguishing this from generic
flakiness.

Related: ClickHouse#106571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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