Repository navigation
Fix flaky test_keeper_snapshot_chunked_transfer[remote_disk] - #102899
alexey-milovidov merged 1 commit into
Conversation
|
cc @kssenii — could you review this? This fixes the remaining flakiness in your test_keeper_snapshot_chunked_transfer test after #102643. The root cause is that the S3 assertion checked for all tmp_snapshot files (catching transient markers from background snapshot flushes), while the local_disk variant correctly checked only the specific interrupted file. |
Pre-PR Validation (Session cron:clickhouse-ci-task-worker:20260416-161500)a) Deterministic repro: Race condition in CI — after Keeper restart, background snapshot flushes ( b) Root cause causal chain: c) Fix matches root cause: Yes — narrows the S3 assertion to check only the specific interrupted transfer's tmp files (matching d) Test intent preserved: Yes — still verifies interrupted transfer tmp files are cleaned up. 15 s timeout catches genuine cleanup failures. e) Both directions: This is a CI race condition. The fix is logically proven: narrowing the assertion scope removes the false-positive path while preserving the true-positive detection. f) Fix is general: The asymmetry between |
|
Workflow [PR], commit [7880ce7] Summary: ✅ AI ReviewSummaryThis PR updates ClickHouse Rules
Final Verdict
|
…ssertion The test_recover_after_interrupted_transfer[remote_disk] test was flaky because it asserted that *all* tmp_snapshot_* files are absent from S3 immediately after restart + sync. After restart, Keeper may create new local snapshots asynchronously (queued via snapshots_queue), which temporarily produce fresh tmp_ markers during serializeSnapshotToDisk. The immediate assertion catches these transient markers as false positives. The local_disk variant was never flaky because it checks the specific tmp file path from the interrupted transfer, ignoring any new markers. Fix: record the specific tmp file names left by the interrupted transfer, then poll for those specific files to disappear (15 s timeout) instead of asserting immediately against all tmp_snapshot_* objects. New transient markers from background snapshot flushes are correctly ignored.
46cb983 to
7880ce7
Compare
|
cc @kssenii — could you take a look? This has been waiting for review since 2026-04-16 (16 days). Status update (2026-05-02):
Recap of the fix: After The fix: snapshot the set of interrupted-transfer tmp filenames at kill time, then poll (15 s) for those specific objects to disappear. Background flushes are ignored. This explains why only CIDB shows the assertion-flake is still active across ~30 unrelated PRs in 30 days and 6 master runs. Two open issues track it: #102040, #101969. Thanks! |
…st_recover_after_interrupted_transfer The test interrupts a chunked snapshot transfer mid-stream, kills the node, restarts it, and asserts that startup cleanup removes the `tmp_snapshot_<idx>.bin.zstd` markers left behind by the interrupted transfer. The polling loop introduced in PR ClickHouse#102899 records `object_name` of the interrupted markers before the kill and re-checks the listing after the restart. This is too loose: when the leader resends a snapshot for the same `log_idx` (common after a kill+restart while no new entries were committed), the new `beginSnapshotReceiveToDisk` call creates a fresh `tmp_snapshot_<same_idx>.bin.zstd`. That new in-flight marker has the *same* `object_name` as the original interrupted marker, so the polling filter mistakes it for the original. The 15-second deadline expires while the new transfer is still in progress and the test fails even though the C++ startup cleanup correctly removed the original file. Match on `(object_name, last_modified)` instead. MinIO returns last_modified with microsecond precision; the original interrupted marker (created before the kill) and any new in-flight marker (created after the restart) always have different timestamps. Genuine cleanup regressions still fail the assertion because the original file's tuple is unchanged. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100146&sha=60fad4c4a87adad7da97b1b7249acf9d6370d4ff&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%204%2F4%29
The
test_recover_after_interrupted_transfer[remote_disk]integration test has been chronically flaky (20+ PRs affected, 6 master failures in 30 days — issues #102040, #101969). PR #102643 added async()call but failures continued (master failure on 2026-04-15 on commit 118bba8 which is ahead of the fix).Root cause
After the node restarts, Keeper may create new local snapshots asynchronously —
serializeSnapshotToDiskis queued viasnapshots_queueand runs in a background thread. During the write, atmp_snapshot_*marker file is created temporarily (removed once the snapshot is fully written to disk).The S3 assertion checked for all
tmp_snapshot_*objects immediately aftersync(). If a background snapshot flush happened to be in progress, its transient marker was caught as a false positive.The
local_diskvariant was never flaky because it checks the specific tmp file path from the interrupted transfer, ignoring any new markers from background operations.Fix
tmp_snapshot_*file names left by the interrupted transfer (before restart)sync(), poll for those specific files to disappear (15 s timeout) instead of asserting immediately against alltmp_snapshot_*objectsThe test still verifies the core behavior: interrupted transfer tmp files must be cleaned up on startup. The 15 s timeout ensures genuine cleanup failures are still caught.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.5.1.251