Repository navigation
Assert the stop itself instead of the clock in the distributed-plan early-stop tests - #117764
alexey-milovidov merged 4 commits into
Conversation
…an oracle on the stop itself 04891_distributed_plan_limit_early_stop and 05024_distributed_plan_limit_early_stop_idle_sink decided PASS/FAIL by elapsed time: a satisfied LIMIT must stop the upstream distributed-plan stages, so a correct run finished in seconds while an unstopped run kept a sleepEachRow scan going and tripped the query's own max_execution_time = 25. The cap therefore fired on any run that was merely slow, which is what CI produces under parallel-suite load, and every recorded failure overshot the cap by 0.3% to 2.6% and was green on rerun. A passing run has been measured at 40.2 s, so no constant threshold separates the two cases. The tests now assert the propagation instead. Each exchange endpoint traces the action it takes when the stop reaches it, and both halves are required for every stream between the LIMIT and the sleeping scan: the sink closing its input and the source sending NoMoreDataNeeded one hop upstream. The expected set of streams is derived from EXPLAIN PLAN distributed = 1 and the two pinned bucket counts, and the receipt of the packet is deliberately not part of the oracle - it predates the fixes these tests guard, so an oracle keyed on it would also be satisfied by the regressed code. A stream that ends by running out of data produces no source-side action, so a normal completion cannot pass for an early stop. max_execution_time becomes a 300 s backstop against a hang. Three LOG_TRACE lines are added inside branches that already ran, so that the in-memory transport is as observable as the streaming one, which already logs both halves. Both tests move from .sql to .sh because the assertion needs a captured query_id and a two-step log join: worker tasks log under their own query_id and are only reachable through initial_query_id, which system.text_log does not have. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings), plus my own cold review
Severity: ❌ blocker / Also verified so a reviewer does not have to: both Session id: cron:clickhouse-review-slot-10:20260902-183400 |
|
Workflow [PR], commit [da64f0b] Summary: ❌
AI ReviewSummaryThis PR replaces the wall-clock oracle in Final Verdict
LLVM Coverage ReportMeasured on commit da64f0b.
Changed lines: Changed C/C++ lines covered: 16/16 (100.00%) · Uncovered code |
Pre-PR validation gate
Other runs: Controls: corrupting one format-string literal turns both tests red, per arm, so a reworded message Note on the design: #115360 named Not done, and flagged rather than claimed: the tests were verified on a debug build only, not on a |
|
cc @davenger @KochetovNicolai, could you review this? |
Build profile diff (arm_release)Comparing commit See the job log for details. |
CI finish ledger - c42c017Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Session id: cron:our-pr-ci-monitor:20260903-040000 |
Both tests identify their own log rows by a query id built from
CLICKHOUSE_TEST_UNIQUE_NAME, which is only unique per database, and then scan
system.query_log and system.text_log from yesterday(). A run can be given a fixed
database for a whole pass over the suite (ci/jobs/scripts/stress/stress.py passes
--database=test_{i} for some of its workers), and a directly executed .sh defaults
to "test" (tests/queries/shell_config.sh:8), so the id repeats and an earlier run's
rows can answer for the current one.
That is a green-while-broken hazard rather than a cosmetic one. max_execution_time
is only a 300s backstop now, so a run whose stop never propagates still returns its
row, which leaves the log assertion as the only thing that can catch it. Measured on
a pinned database with the probe table cut to a single block, so that nothing needs
stopping: the oracle printed "stop propagated on every expected exchange stream" for
both arms and stdout was byte-identical to the reference, i.e. reported OK. The same
run in a fresh database printed MISMATCH on all 12 streams, and with a per-run id it
prints MISMATCH even with the earlier rows present.
Append random_str 8 to the id, as in
01710_projections_partial_optimize_aggregation_in_order.sh.
CI finish ledger - 0d96edeEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Session id: cron:our-pr-ci-monitor:20260908-120121 |
Both conflicts are modify/delete on the two tests this branch converts from `.sql` to `.sh`: master dropped their `no-old-analyzer` tag when it removed the old-analyzer test mode, while this branch deletes the `.sql` files. Resolved by keeping the deletion and carrying master's tag change into the `.sh` replacements, so neither test names a tag that no longer exists. The two source hunks auto-merged. Their anchors survived master's exchange rework: the `no_more_data_needed` early return in `StreamingExchangeSink` and the `isReaderDetached` / `detachReader` sites of the in-memory exchange source are all still there, and master added no trace of its own at any of them, so the oracle still has to rely on the lines this branch adds. Co-Authored-By: Claude Opus 5 <[email protected]>
CI finish ledger - da64f0bEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task CI is fully finished on this head: 176 checks, 153 pass, 20 skipped, 2 failed,
Session id: cron:our-pr-ci-monitor:20260915-190256 |
2f7c7d1
Related: #115360
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
04891_distributed_plan_limit_early_stopand05024_distributed_plan_limit_early_stop_idle_sinkdecided PASS/FAIL by elapsed time. A satisfied
LIMITmust stop the upstream distributed-planstages, so a correct run finished in seconds while an unstopped run kept a
sleepEachRowscan goingand tripped the query's own
max_execution_time = 25. The cap therefore fired on any run that wasmerely slow: every sighting overshot it by 0.3%-2.6% and was green on rerun.
Raising the cap is not the fix, because the correct-run tail is host contention and unbounded in
wall clock. So the tests now assert the propagation. Each exchange endpoint traces the action it
takes when the stop reaches it, and both halves are required for every stream between the
LIMITand the sleeping scan: the sink closing its input, and the source sending
NoMoreDataNeededone hopupstream. The expected stream set comes from
EXPLAIN PLAN distributed = 1and the pinned bucketcounts;
max_execution_timebecomes a 300 s backstop, as in04335_distributed_plan_cancel.sh.The oracle keys on the close, not on the packet's receipt, because the receipt log predates the
fixes these tests guard and would also be satisfied by the regressed code. It matches per stream,
not per exchange, because each bucket is an independently idle endpoint and
ScatterByPartitionTransformkeeps the scan alive while any one output is unfinished. A stream thatruns out of data produces no source-side action, so normal completion cannot pass for an early stop.
src/gains threeLOG_TRACElines inside branches that already ran, no new state.Requested on #115360, where I said I would use
PAUSEABLE_ONCEfailpoints at these sites. Log linesreplace them: a name-keyed failpoint cannot tell the streams of one query apart, and per-stream
identity is what catches a single stuck bucket. It also adds no failpoints to the exchange sinks and
needs no
no-parallel.Validation matrix
Each row is a separate build; each server's
buildId()was asserted against its binary's Build ID.649a4ebd10fc577^dd3d060e23c4846^649a4ebd10fc577^is the primary control: the instrumentation applies cleanly there, so 04891passing while 05024 fails separates the mechanism from the oracle. The three streams that did stop
are the gather directly below the
LIMIT, the only endpoint still active because it delivered therow, so a per-exchange or count-based oracle would have been satisfied by those three. At
dd3d060e23c4846^no log line has a host branch to port onto, sosrc/was left pristine there;the receipt log fires for 3 streams while the close log cannot fire at all, which is why the oracle
keys on the close.
Clock independence: CPU load could not manufacture a slow run on a 384-core box, so the sleep was
moved to the join's build side, which a satisfied
LIMITcannot skip. That query is correct andtakes 36.1 s. At
max_execution_time = 25it givesCode: 159 ... elapsed 25000.147 ms ... While executing ReadFromDistributedPlanSource, the signature of every CI sighting; at300itreturns the right answer with every expected stream stopped.
Other runs:
--test-runs 50on both tests with randomization on, 100/100 green with zero variationin the expected stream set;
--test-runs 16 -j 8self-concurrent, 32/32 green, which is why neitherneeds
no-parallel; regression sweep overdistributed_plan*anddistributed_shuffle*,53 green. Corrupting one format-string literal turns them red, and only the arm whose transport it
belongs to, so a reworded message fails loudly rather than vacuously.
Workflow [PR]
Sync PR [sync-upstream/pr/117764]