Repository navigation
Replace the AggregatingInOrderTransform cancellation test with a failpoint integration test - #114756
Conversation
…point integration test 04512_aggregation_in_order_cancellation.sh guards the per-key-interval cancellation check added in ClickHouse#110104, but it asserts on a measured quantity: aggregation CPU as a multiple of scan CPU, after a shell-issued KILL. It has now been rewritten eight times and prints "not cancelled in time" on master again (5 failures in 24 h on 2026-08-13, 2 of them on master, all on amd_asan_ubsan / distributed plan / parallel). The oracle prices the window between "the rows are read" and "the KILL flips is_cancelled", and two fresh clickhouse-client process startups sit on that critical path. 04410_primes_source_cancellation.sh:44-49 records the in-tree figure: a single client invocation alone can take ~8 s on a loaded sanitizer build. The checkpoint was firing on every failing run, stopping at 52-75 % of the loop rather than 100 %; only the window grew. The race cannot be closed from the shell either, because read progress is published after the source's work() returns (ExecutionThreadContext.cpp:57-75), so nothing shell-visible indicates that the aggregation loop is running. Adopt the deterministic mechanism LimitByTransform already uses (e20a673, then d811a21 and 0fa0ea3): a PAUSEABLE_ONCE failpoint on the sixth key interval, placed after the cancellation check and inside the loop, plus a LOG_TEST marker in the existing cancellation branch. The new integration test pauses there, kills the query, resumes, and asserts the marker appears. That assertion is structural and load-invariant, with no timing, threshold or free constant. The mid-loop placement is deliberate. A pre-loop pause would resume straight into the first isCancelled(), so the test would stay green even if that check were hoisted out of the loop, which is precisely the bug ClickHouse#110104 fixed. Both mutation arms were verified to redden: deleting the checkpoint, and hoisting it out of the loop. Deleting the 40 M-row fixture also removes its max_estimated_execution_time exposure on slow storage, which was a second, independent failure mode of the same test. The failpoint costs nothing when disabled: pauseFailPoint expands to if (fiu_fail(name)) [[unlikely]] and sits behind an integer compare, so it is reached at most once per consume(). Measured over 40 M key intervals, base vs patched interleaved: 11.515 s vs 11.503 s user CPU. The marker assertion counts lines rather than testing for presence. The marker is emitted inside the cancellation branch and isCancelled() reads an atomic that stays true once set, so deleting only the return re-enters the branch on every remaining iteration: the marker would print once per key interval while the loop still aggregates to completion. Requiring exactly one line rejects that mutation (94 lines on the 100-interval fixture) and keeps rejecting a deleted or hoisted check (0 lines), with no timing term.
Internal second-model review (2 rounds, 0 open blockers)An independent reviewer and a second model reviewed this change cold, without the author's
Checks re-run independently rather than carried over: the failure counts quoted in the |
|
Workflow [PR], commit [ca72e0f] Summary: ✅
AI ReviewSummaryThis PR removes the flaky stateless Final Verdict✅ No findings. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 14/14 (100.00%) · Uncovered code |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260814-031300 |
|
cc @nihalzp @nickitat, could you review this? It replaces the chronically flaky |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units8 translation units recompiled, 13 s compile time in total, 8 of them have a recent master baseline. |
CI finish ledger - 89355d8Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task CI is fully finished on this head and there are no failures to own: 177 leaves, praktika
Session id: cron:our-pr-ci-monitor:20260814-133000 |
|
Yes, this test should better be deleted. But I can merge this PR first. |
|
@alexey-milovidov to be sure I follow up on the right one: this PR already deletes If you also meant the new |
|
📊 Cloud Performance Report ✅ AI verdict: This PR only adds a test-only failpoint, a per-interval counter, and a cancellation-branch log line to the in-order aggregation transform; it changes no query-execution logic and can only add negligible work, never remove it. All 11 flagged results are improvements, so none can be caused by this change, and they have been downgraded to not_sure as run-to-run and co-location variance (the source ran fewer repetitions, and Q23 in particular was highly noisy). The large-delta rows (ClickBench Q23, TPC-H Q7 x8.1 faster and Q8 x2.2 faster) were not locked by the deterministic trust override and are treated the same way. No envelope-suppressed rows were present to reconcile. clickbenchFlagged queries (9 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_officialFlagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
|
🕵 Merged current The remaining question from the approved review is whether the new replacement integration test should also be removed. That is a maintainer decision; no further mechanical change is implied by the existing feedback. |
Related: #110104
Related: #107941
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
04512_aggregation_in_order_cancellation.shguards the per-key-interval cancellation check from#110104, but asserts on aggregation CPU as a multiple of scan CPU after a shell-issued
KILL. Itprints
not cancelled in timeon master again: 6 such failures on 2026-08-13 (2 on master, 4 onunrelated PRs), 5 on
amd_asan_ubsan, distributed plan, parallel. Eighth rewrite of the assertion.The oracle prices the window between "rows are read" and "the
KILLflipsis_cancelled", and twoclickhouse-clientstartups sit on that path;04410_primes_source_cancellation.sh:48-49records~8 s for one invocation on a loaded sanitizer build. On all five failures that printed the CPU
diagnostics the checkpoint was firing, stopping at 48-75 % of the loop, not 100 %: only the window
grew, and the shell cannot close it, since read progress is published only after the source's
work()returns (ExecutionThreadContext.cpp:57-75).So this adopts the mechanism
LimitByTransformalready uses (e20a67394329867and follow-ups):a
PAUSEABLE_ONCEfailpoint on interval 6, after the cancellation check and inside the loop, aLOG_TESTmarker in the existing cancellation branch, and an integration test that pauses there,kills, resumes and asserts the marker appears exactly once. No timing, no threshold, no free
constant. Exactly once, not merely present:
is_cancelledlatches, so dropping only thereturnprints the marker once per remaining interval (94 here) while every other assertion still passes.
Mid-loop matters for the same reason: a pre-loop pause resumes straight into the first
isCancelled(), staying green with that check hoisted out of the loop, which is what #110104 fixed.All three mutations (checkpoint deleted, check hoisted,
returndeleted) redden the new test, thefailpoint still pausing in each so no arm is vacuous. Removing
SYSTEM ENABLE FAILPOINTfailsloudly;
test_limit_by_transform_kill_querystays green. Hot-path cost is not measurable, anddropping the 40 M-row fixture removes its
max_estimated_execution_timeexposure.04409_skip_index_build_cancellation.shhas a weaker form of the same pattern (boundedKILL ... SYNCattimeout 10); left unchanged.