Repository navigation
Fix flaky tests 03100_lwu_15_future_reads and 03100_lwu_16_future_reads - #109429
alexey-milovidov merged 6 commits into
Conversation
Two independent races made these lightweight-update "future reads" tests flaky (seen on master and across unrelated PRs, "result differs with reference"): 1) Patch-part count race (03100_lwu_15). After the scenario, OPTIMIZE FINAL folds both patches into the base part, so the two patch parts become redundant and the background cleanup thread (clearUnusedPatchParts, gated by the remove_unused_patch_parts setting, default true) legitimately drops them. The assertion "SELECT sum(rows) ... startsWith(name,'patch') = 200" then races that cleanup and observes 100 or 0. Data is always correct (sum(v) = 799500 with or without patch parts). Pin remove_unused_patch_parts = 0 on the table so the redundant patch parts are not removed before the count is read. This matches 03100_lwu_01_basics.sql, which already pins the setting for the same reason. 2) wait_for_block_allocated timeout (both tests, shared helper in parts.lib). On a busy machine the helper's ~30s polling budget (100 x 0.3s, each iteration doing a synchronous SYSTEM FLUSH LOGS zookeeper_log) could expire before the block-create event appeared in system.zookeeper_log, and it then printed "Failed to wait for block ..." to stdout, polluting the test output (the failpoint only sleeps 3s, so the timeout was purely load-induced). Increase the budget to ~90s and, matching the sibling helpers wait_for_delete_empty_parts / wait_for_delete_inactive_parts, send the failure message to stderr and return non-zero so a genuine timeout fails loudly instead of silently corrupting stdout. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-2:20260705-051400 |
|
cc @CurtizJ — could you review this test-only fix? It de-flakes 03100_lwu_15/16_future_reads: (1) pins |
|
Workflow [PR], commit [6520e1b] Summary: ✅ AI ReviewSummaryThis PR de-flakes the lightweight-update future-read tests by hardening Final Verdict✅ Approve. No new inline review comments. |
Addresses review feedback on parts.lib. The wait_for_block_allocated helper now returns non-zero on timeout, and its callers run it under set -e right after enabling the server-global ONCE failpoint rmt/smt_lightweight_update_sleep_after_block_allocation. If block allocation never happens, the script aborts at wait_for_block_allocated before it can wait for the background client or disable the failpoint. ONCE failpoints stay enabled until they are consumed or explicitly disabled, and system.fail_points is process-global (documented in 03916_system_fault_injection_points.sql), so a single genuine timeout would arm the failpoint for a later unrelated stateless test and turn this de-flake into a new cross-test flake. This was already a latent leak for any query failing under set -e between ENABLE FAILPOINT and the end of the script; the non-zero return just makes it reachable. Add a trap cleanup EXIT to all five callers (03100_lwu_13/14/15/16/28) that disables the failpoint and reaps the background client on every exit path, including the timeout abort. The cleanup swallows its own errors so it never changes the script exit code, and disabling an already-consumed ONCE failpoint is a harmless no-op. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Good catch, addressed in 0705d22. You're right that turning the timeout into a non-zero return leaks the process-global ONCE failpoint under Fix: added a Verified on a debug build (external Keeper), both directions:
Also: 50x each of |
The EXIT trap added in the previous commit disables the failpoint and reaps
the background client, but on the wait_for_block_allocated hard-timeout path
the script exits before its normal DROP TABLE, leaving the replicated table
(and its zookeeper path) behind. Under clickhouse-test --order=random that can
poison a later test that reuses the same zookeeper path (e.g. 03100_lwu_24
registers t_lwu_renames on the same /zookeeper/{database}/t_lwu_on_fly/ path).
Add a best-effort DROP TABLE IF EXISTS ... SYNC to the cleanup function of all
five callers (13/14/15/16/28) after the wait, guarded with || true so it never
changes the script exit code.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Good catch, addressed in cf89d9c. You're right that the Fix: added a best-effort Verified on a debug build with a forced
The timeout still returns non-zero (hard failure preserved), and 30x each of |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 100 line(s), 4 function(s) across 46 file(s) · Details Top files
|
CI finish ledger — cf89d9cEvery failure below has an owner: a fixing PR (ours or external). This is a test-infrastructure-only PR (
Reports:
Session id: cron:our-pr-ci-monitor:20260705-173000 |
The five tests 03100_lwu_13/14/15/16/28 all enable the same server-global ONCE failpoint rmt_lightweight_update_sleep_after_block_allocation (or the smt_ variant under s3_with_keeper). The failpoint API is name-only (FailPointInjection::enableFailPoint / disableFailPoint take just the name, and the SYSTEM ENABLE/DISABLE FAILPOINT grammar parses a bare identifier), so there is no table, database or query-id key that could scope an enable to one test. Unique table names therefore cannot make these tests safe to run concurrently with each other. Until this change the tests were parallel-eligible, so two of them could interleave between one test's SYSTEM ENABLE FAILPOINT and the fiu_do_on site in StorageReplicatedMergeTree::updateLightweight: the sibling could consume the ONCE failpoint, or its EXIT cleanup could disable it, and the intended 3s pause window would be lost, making the future-read scenario scheduler-dependent again. no-parallel makes clickhouse-test run them in the sequential group, which executes after the parallel workers. Coverage is not lost: the runner maps the sequential job flavor to --no-parallel, 14 stateless jobs use that flavor, and the flaky check still reruns sequential tests via --sequential-test-runs. Co-Authored-By: Claude Fable 5 <[email protected]>
The stateless test profile installs insert_keeper_fault_injection_probability = 0.01 (tests/config/users.d/insert_keeper_retries.xml, linked in by tests/config/install.sh). 03100_lwu_13, _14 and _28 already set it to 0 before their replicated insert; _15 and _16 did not. Both tests then poll for the exact znode block-0000000001. The initial INSERT allocates its block through ZooKeeperWithFaultInjection, and an injected failure after a successful create consumes that block number, so the retry takes the next one and the background UPDATE's block is no longer block-0000000001. wait_for_block_allocated then polls its whole budget and the intended pause window is lost. Pinning the setting to 0 makes the block numbering deterministic and brings these two tests in line with their three siblings. Co-Authored-By: Claude Fable 5 <[email protected]>
CI finish ledger - 6520e1be25897b1f2ba3dcbf3ee5b04b2fbfa7a1No failures on this head, so there is nothing to assign an owner to.
174 of 174 check-runs completed (56 success, 118 skipped). For the record, the one failure on the previous head Session id: cron:our-pr-ci-monitor:20260729-213000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes two independent races that made the lightweight-update "future reads" tests
03100_lwu_15_future_readsand03100_lwu_16_future_readsflaky. Both were observed on master and across several unrelated PRs asresult differs with reference(also asFailed to wait for block ...extra output line, and occasionally return-code timeouts under load). No related open issue found.1) Patch-part count race (
03100_lwu_15). After the scenario,OPTIMIZE ... FINALfolds both patch parts into the base part, so the two patch parts become redundant. The background cleanup thread (MergeTreeData::clearUnusedPatchParts, gated by theremove_unused_patch_partssetting, defaulttrue) then legitimately drops them. The assertionraces that cleanup and observes
100(one patch dropped) or0(both dropped). The data is always correct:sum(v) = 799500both with and without patch parts, because the updates are already reflected in the base part. Pinningremove_unused_patch_parts = 0on the table keeps the redundant patch parts around until the count is read, making the assertion deterministic without weakening it. This matches03100_lwu_01_basics.sql, which already pins the same setting for the same reason.2)
wait_for_block_allocatedtimeout (both tests, shared helper inparts.lib). On a busy machine the helper's polling budget (100 x 0.3s, each iteration doing a synchronousSYSTEM FLUSH LOGS zookeeper_log) could expire before the block-create event appeared insystem.zookeeper_log. The failpoint only sleeps 3s, so any timeout is purely load-induced. On timeout the helper printedFailed to wait for block ...to stdout, polluting the test output and producing theresult differsdiff. The budget is increased to ~90s, and, matching the sibling helperswait_for_delete_empty_parts/wait_for_delete_inactive_parts, the failure message now goes to stderr with a non-zero return so a genuine timeout fails loudly instead of silently corrupting stdout.Both fixes were reproduced and validated locally in both directions (fails without the fix, passes with it); the three other consumers of
wait_for_block_allocated(03100_lwu_13,_14,_28) continue to pass.