Repository navigation
Conversation
A case that reports no elapsed time can be in one of three states, and the single "no timeout" verdict named only the third: the query finished inside its deadline, it failed for some unrelated reason, or the in-function checkpoint really is missing. Only the last is a cancellation defect, and the first two need the case re-sized rather than the function fixed. That cost a misdirected investigation round. The 04650 case "one match, long instruction list" reported "no timeout" on two arm_binary runs, and its own query_log rows show QueryFinish at 993 ms and 997 ms with exception_code 0 against a 1000 ms deadline - the query succeeded, so there was no timeout to report and the verdict was accurate but unhelpfully worded. Key on the client's exit status, which distinguishes the three directly: 0 for a completion, 159 for TIMEOUT_EXCEEDED, and anything else for an unrelated failure whose code is now printed. All three verdicts remain reference mismatches, so nothing is weakened and the same runs would still have gone red; the failing line now names the cause. On an unfixed binary the "expanding replacement" case consequently reports a memory limit by code instead of an absent timeout. The reference file is unchanged: these strings are only ever printed on failure.
A folded case that times out without the in-function checkpoint reports no elapsed number, and the oracle fell back to bounding the client's wall clock against twice the bound. That is not the invariant this test exists to assert, and it made cases pass on a build with no checkpoint at all: with the pre-fix headers, six of the eight folded cases matched the reference exactly. Two messages report the same enforced deadline and only one carries a number. checkTimeLimit passes watch.elapsed(), which is never zero, so a stop this function made always carries the elapsed part; addPipelineExecutor and throwIfKilled pass a literal zero, so a stop nothing inside the function participated in never does. For a folded call the second form means the deadline was crossed either entirely before entry or entirely after the last fold, and both are that case's own sizing to fix - so it is now a named failure rather than a wall-clock pass. On a fixed build the checkpoint runs at entry, after materialization and inside every loop, so there is no path by which a correctly sized case reaches it. Requiring the stronger signal also removes the squeeze that made the sizing unsatisfiable, because a case no longer has to outrun a wall-clock threshold. Each folded case is then sized by one rule: the step this fix cannot interrupt stays a small part of its deadline on the slowest build, and its total work outlasts the deadline by a wide margin on the fastest one. Cases 1 and 11 split one large fold into many small ones, which shrinks the uninterruptible step without changing total bytes - measured, the reported prologue tracks one fold's constant and not the array's total, so at 200 folds of 1MB it falls from 806ms to about 50ms on a thread-sanitizer build while the work is unchanged. Cases whose work cannot be grown set an earlier deadline instead, which moves the deadline into the work: case 15's cost is its own output and that output is already within ten percent of the test memory profile, so no larger fixture exists. A per-case deadline is fractional, and Seconds truncates to whole milliseconds, so what the server actually enforced is read back from its own message rather than assumed. At the shared deadline every bound is unchanged, so no existing case is widened.
Case 21 inserted 40 identical 1MB rows. A block of repeated haystacks can be answered by matching once and copying the result per repeat, so the row count bought no work: measured against PR ClickHouse#111005, which adds exactly that cache, growing 40 to 640 identical rows costs 1.4x while 40 to 640 distinct rows costs over 11x. The case's total work fell from 6.5 s to 1.7-2.3 s on a debug build, which on the faster arm_binary release build lands inside the 1 s deadline, so the INSERT completed and the test reported "no timeout" - the third failure shape seen since this test merged, on ClickHouse#111005 at 3478592. The rows are now distinct at the same width and the same total bytes, and the case takes its own 0.2 s deadline through run's existing sixth parameter. The earlier deadline is needed independently: at the shared deadline the bound is deadline + ALLOWANCE = BOUND, so a stop can never be reported before half of it, and the fixed-arm criterion is unsatisfiable by construction. Total work is now 33x the deadline on the fast arm and 196x under the carrier's own code, against a reported elapsed of 0.15-0.51x the bound on debug, tsan and the fast arm. On a build with the three Functions/ headers reverted the case reports OVERSHOT 38690 ms, and all 19 run cases now fail there - none report "stopped within bound". Two comment blocks that restated measurements are condensed. Co-Authored-By: Claude Fable 5 <[email protected]>
Internal second-model review (click to expand)Independent cold review plus a second-model gate, adjudicated against the recorded evidence. Rounds Final gate: 0 findings (scope confirmed: full diff 63/33, fix-round delta 8/7). All findings below
Independently re-verified rather than accepted: the two-channel argument re-derived from source at Disclosed, not absorbed: cases 19, 20 and 22 fail intermittently on the local 56-slot build box at Session id: cron:clickhouse-review-slot-10:20260802-215100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-45:20260802-141400 |
|
cc @rschu1ze, could you review this? It is test-only: the folded cases in 04650_replace_cancellation fell back to bounding the client's wall clock whenever the server's timeout message carried no elapsed number, which a build with no in-function cancellation check also satisfies, so those cases could pass while asserting nothing. They now require the numbered channel, and two fixtures are re-sized rather than the bounds widened. |
|
Workflow [PR], commit [759a98b] Summary: ✅ AI ReviewSummaryThis PR hardens Final Verdict✅ No findings. |
CI finish ledger — 759a98bEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
All 175 check-runs are complete: 58 success, 117 skipped, 0 failures. The Session id: cron:our-pr-ci-monitor:20260803-030000 |
There was a problem hiding this comment.
Done in 9d2bf8e. The file had 169 comment lines against 197 of code, with 17 blocks over three lines; it is now 92 against 200, one block over three (the tag rationale). Comments only, no executable line changed, so the reference is untouched and the test still passes locally.
I cut everything a reader can get from the commits: the measurements that decided each fixture size, the history of what earlier versions got wrong, and the restatements of the PR description. I kept only what is not re-derivable at that spot, mostly the "violate this and the case is vacuous" constraints: the needle must vary in case 8, the haystack must be materialized in case 25, the rows must be distinct in case 21.
Noted as a standing preference, not a per-PR nit.
There was a problem hiding this comment.
@groeneai maybe the test is still going to be flaky, just dont care if the query finishes on time or not. on sanitized builds, cancellation is going to be triggered anyway
There was a problem hiding this comment.
You are right that cancellation fires anyway on a sanitized build, and that is exactly why "it got cancelled" cannot be the oracle: it fires on the unfixed build too, from CancellationChecker or the executor's between-block check. So the assertion has to be that the stop came from inside the function. Whether the wall clock is also worth asserting then splits by case shape, and the two halves of the suite answer differently.
For the 8 folded cases your proposal is already what the file does. No pipeline exists while a fold runs, so no executor check and no cancelTask path, and the only reachable producer of an elapsed N ms number is the in-function check (checkTimeLimit passes watch.elapsed(); addPipelineExecutor and throwIfKilled pass a literal zero). Requiring the number is the cancellation-happened assertion. And that number is the server's own elapsed at the instant it stopped, not the client's wall clock, so it does not drift with load: on tsan at a 1000 ms deadline the eight report 1000-1044 ms against a bound of 4000. The flaky part for folds was never the comparison, it was whether the case reaches the checkpoint at all, which is what this PR re-sizes.
For the 11 pipeline cases the bound is the whole oracle, and dropping it would make every one of them pass unconditionally on a build with no in-function checkpoint. With the three Functions/ headers reverted, all 11 still report a number, from the executor: 2575, 2952, 3124, 9781, 11002, 11080, 13226, 13572, 38690, 39355, 59413 ms. The number is worthless there precisely because the executor also produces it, so only its size distinguishes the builds. That is the vacuous oracle this PR removes, and I would rather not put it back.
On "maybe still flaky": yes, on master today, and the two newest hits are the shape this PR fixes. Both are one match, long instruction list: no timeout (case 15, which takes a 0.2 s deadline here) and both landed after I froze the census in the description: 113039 and 112928. Over 10 days every failing verdict is one of the three shapes addressed here; none is a bound that is simply too tight.
If it still goes red after this, I would rather drop the offending case than relax its assertion, and I will do that promptly. Happy to go that way now if you prefer it.
|
Better fix here #113031 |
|
One caveat on the commit I referenced above: |
|
Correction to my previous comment: the reason this PR's head did not move is that you had closed it at 09:18:25Z, half an hour before I pushed. My guess at GitHub degradation was wrong, and I should have re-read the PR state before speculating. Sorry for the noise. Understood on #113031 for case 15, and thanks for pushing it through. It fixes the shape that was actually red in CI, and it does it with a smaller diff than mine: the two newest carriers I found this morning (113039 at 50efca4, 112928 at a1d5ec4, both One thing that closing this PR leaves behind, which I mention only so it is written down rather than to reopen anything. The folded branch in Only That is a hole in what the test asserts rather than a red run, so it can sit until it matters. If you would like it closed I am happy to send just that branch as a few lines, separately from the sizing work you have already taken. Otherwise I will leave it. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
04650_replace_cancellation(mine, from #112483) has gone red since it merged on five unrelatedauthors' PRs and once on master, in three shapes:
fold regexp: OVERSHOT 4096 mson amd_tsan, and onarm_binary
one match, long instruction list: no timeoutandstored expression: no timeout.The oracle is at fault, not the bounds. Two messages report the same enforced deadline and only one
carries a number:
checkTimeLimitpasseswatch.elapsed(), never zero, so it always printselapsed N ms, whileaddPipelineExecutorandthrowIfKilledpass a literal zero. The test extractsthat number, and when it was missing for a folded case it fell back to bounding the client's WALL CLOCK,
which a build whose in-function checkpoint never ran also satisfies. With the three
Functions/headers reverted, folded cases pass while asserting nothing (three to six of eight, varying with load).
A folded case must now report the numbered channel. No number means the checkpoint did not participate,
which is that case's own sizing to fix, and it is named that way. Cases whose work cannot be grown set
an earlier deadline instead, keeping the same allowance, so every bound at the shared deadline is
unchanged. Two are also split into smaller folds.
The third shape is a fixture bug: the stored-expression case inserted 40 identical 1MB rows, the best
case for the per-block haystack dedup proposed in #111005, so under that change its row count bought no
work and the query completed. Its rows are now distinct at the same width and total bytes, which no such
cache can collapse. On the unfixed build all 19 cases fail.
No
src/change,.referencebyte-identical, no case weakened, nono-random-*tag added. Validatedon debug and thread-sanitizer builds in both fix states, plus release binaries as a fast arm.
Failing CI runs and per-case sizing
One report per shape, all
Stateless tests (sequential):amd_tsan,
arm_binary
case 15,
arm_binary
case 21,
and
master.
Two further arm_binary runs repeat the case-15 shape.
bound = deadline_ms + ALLOWANCE,ALLOWANCE = BOUND - 1000. A case discriminates when the fixedarm's elapsed is under half its bound and the fast arm's work is at least 5x its deadline. Numbers
below are thread-sanitizer.
Splitting works because the prologue tracks one fold's constant, not the total.