Repository navigation
Fix flaky test_shutdown_cancels_backup and test_long_disconnection_stops_backup - #108459
Conversation
…ops_backup Both tests trip NoTrashChecker.__exit__ when a transient ZooKeeper/network error lands in the checker's error-collection window: - test_shutdown_cancels_backup restarts a node mid-backup; the surviving node briefly loses its connection to the restarting peer and to Keeper, so KEEPER_EXCEPTION/NETWORK_ERROR can appear. The test declared no allow_errors, so the checker failed. Allow the same transient-error family the sibling disconnection tests already allow. - test_long_disconnection_stops_backup populated allow_errors only near the end of the body. When the body raised earlier (e.g. a transient SOCKET_TIMEOUT during the BACKUP setup), __exit__ ran with empty lists and masked the real failure with a spurious assertion. Move the relaxations to right after entering NoTrashChecker. Also drain backups from a previous test before creating the NoTrashChecker in all four affected tests (tests run in random order), via a shared helper that replaces the inline blocks duplicated in the two short-disconnection tests. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260625-102900 |
|
cc @vitlibar — could you review this test-only fix? It widens the |
|
Workflow [PR], commit [1649377] Summary: ✅ AI ReviewSummaryThis PR is a test-only hardening for Final VerdictStatus: ✅ Approve |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 851 line(s), 77 function(s) across 137 file(s) · Details Top files
|
`test_cancel_backup` and `test_cancel_restore` assert that a cancellation is prompt, but they measured it with a client-side `time.monotonic()` stopwatch spanning `kill_query` through `wait_status`. In this harness every `node.query(...)` is a `docker exec` of a fresh `clickhouse-client` (0.5-1 s each), and that window held three to four of them plus `wait_status`'s whole-second poll quantum, so the assertion bounded harness round-trip overhead rather than the cancellation. The result was a chronic flaky failure: 24 rows over 25 days across 13 pull requests, two of them on master. Decomposing all 12 rows of that signature family with timestamps the test already prints, the engine-side cancellation was 1.90-3.24 s (median 2.33) in every single failure against harness overhead of 2.94-5.91 s. The engine cancelled promptly every time; only the measurement was wrong. Measure the same interval between two server-recorded endpoints instead: the KILL query's own `query_start_time_microseconds`, read from `system.query_log` by an explicit `query_id`, and the initiator's `system.backups.end_time`. No `clickhouse-client` launch is inside that interval, while the cluster-wide cancellation still is -- `end_time` is stamped at the terminal transition, which the initiator reaches only after `waitOtherHostsFinish`, so distributed propagation remains bounded. Taking the start from the KILL statement itself matters: in one recorded run a single client-to-server transition stalled 4.192 s, which alone would consume the whole budget. The bound stays at 6 s. One assertion in, one assertion out, and no second oracle: `query_duration_ms` was deliberately removed from this file in 19bcc55 and consolidated into the single end-to-end bound in c26e0b4. Separately, hoist `no_trash_checker.allow_errors` to checker entry so a body failure surfaces as itself rather than being masked by `NoTrashChecker.__exit__` asserting with both relaxation lists still empty -- which is what CIDB reported for this test, hiding the real assertion. `allow_errors` is the correct one to hoist because `__exit__` treats `expect_errors` as must-have-been-observed, so hoisting that would create a new mask with inverted polarity for any failure occurring before the cancellation. This matches ClickHouse#108459, which hoisted `allow_errors` for two sibling functions in this file. Co-Authored-By: Claude Opus 5 <[email protected]>
…ter-flaky-allow-errors Fix flaky test_shutdown_cancels_backup and test_long_disconnection_stops_backup
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes two flaky modes in
test_backup_restore_on_cluster/test_cancel_backup.py. Both tripNoTrashChecker.__exit__(the "no unexpected errors" assertion) when a transient ZooKeeper/network error lands inside the checker's error-collection window. PR-only flaky, master clean.test_shutdown_cancels_backup: it restarts a node mid-backup, so the surviving node briefly loses its connection to the restarting peer and to Keeper, producingKEEPER_EXCEPTION/NETWORK_ERROR. The test declared noallow_errors, so the checker asserted. Now allows the same transient-error family the sibling disconnection tests already allow. Theexpect_errors=["QUERY_WAS_CANCELLED"]requirement is unchanged.test_long_disconnection_stops_backup:allow_errorswas set only near the end of the body. When the body raised earlier (e.g. a transientSOCKET_TIMEOUTduring the BACKUP setup),__exit__ran with still-empty lists and masked the real exception with a spurious assertion. The relaxations are now set immediately after enteringNoTrashChecker.Also drains backups left running by a previous test before creating the
NoTrashCheckerin all four affected tests (tests run in random order in CI), via a sharedwait_for_backups_to_finish()helper that replaces the drain blocks previously duplicated inline in the two short-disconnection tests.Related to #89286 (engine-side cancellation-ordering change, ZooKeeperImpl.cpp); this PR is the orthogonal test-side hardening.
Version info
26.7.1.137