Repository navigation
Fix flaky test_recover_from_snapshot_with_chunked_transfer - #103767
alexey-milovidov merged 1 commit into
Conversation
The test creates a kazoo client for the lagging node before `stop_clickhouse(kill=True)`, then reuses the same client after restart to assert post-recovery state. Under CI load the kill+restart window can exceed the 30 s default kazoo session timeout, after which the session is irrecoverably expired and the client raises `ConnectionClosedError` on the next request — even with the wrapper's implicit retries. Re-create the kazoo client after the restart, matching the pattern used by every other test method in this file (e.g. `test_recover_after_interrupted_transfer`, `test_recover_with_chunk_size_larger_than_snapshot`, `test_recover_after_s3_read_error_during_transfer`, `test_recover_from_snapshot_sent_by_old_leader`). Failure example (from CIDB): - PR ClickHouse#103394 / amd_tsan / `local_disk` variant - assertion `lagging_zk.get(prefix)[0] == b"somedata"` raised `kazoo.exceptions.ConnectionClosedError: Connection has been closed` Chronic in CIDB: 11 distinct PRs and 1 master hit over 30 days, including PR ClickHouse#100332 (12 hits) and PR ClickHouse#101757 (12 hits) — both completely unrelated to Keeper. Open tracking issues: ClickHouse#102040 and ClickHouse#101969. Local validation: - pytest run of `[local_disk]` variant passes cleanly with the fix (setup 18.8 s, call 5.6 s, teardown 6.4 s). - Structural argument: the four sibling test methods in the same file already create `lagging_zk` after the restart and never exhibit this failure mode.
Pre-PR Validation Gate (Session cron:clickhouse-ci-task-worker:20260430-054500)a) Deterministic repro? The chronic flake is timing-dependent — kazoo session expiry under CI load (kill+restart > 30 s default session timeout). Cannot deterministically repro on a fast local machine. The deterministic indicator is the CIDB pattern: 11 distinct UNRELATED PRs hit it in 30 days, plus 1 master hit on 2026-04-21. The recent failure on PR #103394 is a CI-load timing manifestation of this same chronic bug. b) Root cause explained? c) Fix matches root cause? Re-create the kazoo client AFTER
Not a band-aid — it brings the failing test method into structural alignment with its 4 sibling methods that have never exhibited this failure. d) Test intent preserved? All assertions retained:
The kazoo client object is just an inspection tool for ZK state — it has no semantic meaning across the kill. Re-creating it changes nothing observable about the test. e) Both directions demonstrated?
f) Fix is general? Verified — only |
|
cc @kssenii — could you review this? Test-only fix per @alexey-milovidov's directive on #103394. The failing test method created its lagging-node kazoo client before |
|
Workflow [PR], commit [859aaee] Summary: ✅ AI ReviewSummaryThis PR fixes a flaky integration test by recreating the lagging-node ClickHouse Rules
Final VerdictStatus: ✅ Approve |
1ffba8f
Description
The integration test
test_recover_from_snapshot_with_chunked_transfercreates a kazoo client for the lagging node beforestop_clickhouse(kill=True), then reuses the same client after restart to assert post-recovery state. Under CI load the kill+restart window can exceed the 30 s default kazoo session timeout, after which the session is irrecoverably expired and the client raisesConnectionClosedErroron the next request — even with the wrapper's implicit retries.This PR re-creates the kazoo client after the restart, matching the pattern used by every other test method in the same file (
test_recover_after_interrupted_transfer,test_recover_with_chunk_size_larger_than_snapshot,test_recover_after_s3_read_error_during_transfer,test_recover_from_snapshot_sent_by_old_leader).Failure example
CI failure that triggered this fix — PR #103394,
Integration tests (amd_tsan, 6/6):CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103394&sha=ad4662b27bacbf2146f3ece6456168c7b713946c&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%206%2F6%29
Chronic flakiness in CIDB
30-day window:
The PR-relatedness of failing PRs has been verified — none of them touch Keeper code, and they are spread across unrelated areas (PREWHERE/IN-subquery, throw on unknown config, exact subcolumn match, JSON/text index, skip index aggregation, PK analysis stats,
!subranges.empty()logical error, MongoDB cleanup, Azure validation). This rules out a real regression and confirms a chronic test-side flake.Why kazoo cannot recover
tests/integration/helpers/kazoo_client.pywraps every operation inself.retry(...), so transient disconnections are handled. Butstop_clickhouse(kill=True)followed by a slow restart eventually exceeds the kazoo session timeout (30 s by default inget_fake_zk). Kazoo distinguishesLOST(transient) fromEXPIRED(terminal); once a session isEXPIREDthe client moves to a closed state and no retries can resurrect it. The freshget_fake_zkcall after restart establishes a new session.Local validation
python3 -m ci.praktika run "integration" --test "test_keeper_snapshot_chunked_transfer/test.py::test_recover_from_snapshot_with_chunked_transfer[local_disk]" --workers 1— passes cleanly:The chronic flake is timing-dependent (kazoo session expiry under CI load), so it cannot be deterministically reproduced on a fast local machine. The structural argument is the strong proof: with this change, the failing test method now follows the same client-recreation pattern as the four sibling test methods in the file that have never exhibited this failure mode.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not for changelog.
Documentation entry for user-facing changes
Version info
26.5.1.233