Skip to content

Remove the too tight max_execution_time pin from 02524_fuzz_and_fuss_2 - #112251

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:unpin-max-execution-time-02524-fuzz-and-fuss-2
Jul 28, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:unpin-max-execution-time-02524-fuzz-and-fuss-2

Conversation

@groeneai

@groeneai groeneai commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

02524_fuzz_and_fuss_2 fails on Stateless tests (amd_msan, WasmEdge, parallel, 2/2) with

Code: 159. DB::Exception: Timeout exceeded: elapsed 11056.432 ms, maximum: 9000 ms. (TIMEOUT_EXCEEDED)
(query: INSERT INTO data_a_02187 SELECT * FROM system.one SETTINGS ... max_execution_time = '9' ...)

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111996&sha=45889523a9d342ccecedb8dce69081922db4bee5&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%202%2F2%29

The 9000 ms is not a CI default and is not randomized. It comes from one token in the test's own
SETTINGS blob, and I remove that token here.

Root cause. max_execution_time is a wall-clock deadline, not a work budget: it is
registered once per query in ProcessList.cpp:381 and a background thread cancels the query
when that wall time elapses (CancellationChecker.cpp:37-44). In the failing job's server log,
the query (114e12ad-cc2d-41e4-9621-449dbdd06530) logs its last pipeline line at
15:49:36.864398, then nothing at all for 9.000839 s, then
15:49:45.865237 CancellationChecker: Cancelling the task because of the timeout: 9000 ms. In
that same window the server logged 2396 lines across 120 other query ids. So a one-row
INSERT ... SELECT * FROM system.one was descheduled past its own deadline under load. Nothing
in the statement got slower.

Why removing the pin does not weaken the test. The test was added in 773184d as a
test for #38729 (Block structure mismatch in Pipes stream: different types), so what it
asserts is that this fuzzed statement does not produce a block-structure mismatch. Its
.reference file is empty, it contains no serverError or clientError expectation, and
EXPLAIN PIPELINE of the statement is byte-identical with and without the token (39-line graph,
same md5), so the setting shapes no plan. After the removal the statement runs at the server
default max_execution_time = 0, so no deadline task is registered at all
(CancellationChecker.cpp:85-89 returns early for a non-positive timeout). The test stays bounded
from outside: the client stops waiting after its own receive_timeout, which is the client config
default of 300 s and not the receive_timeout = '10' in this blob, and clickhouse-test kills
the test process at --timeout (600 s). In the flaky check, which runs a test repeatedly, a run
longer than TEST_MAX_RUN_TIME_IN_SECONDS (180 s) is failed as too long as well.

Why not raise it again. #67867 already raised this same pin from 3 to 9 for this same class
of failure. A larger constant would be the third value for one defect and would still be a
wall-clock race. The numbers say no constant is safe here: over passing runs in the last 30
days, this test FILE takes p50 2170 ms / p95 3210 ms on amd_msan, WasmEdge, and 24 of 8051
passing runs on that flavour already exceed 9000 ms for the whole file. A 9 s cap on one
statement inside such a file has no headroom by construction.

Breadth. Over 60 days this test has 5 failures across 5 pull requests and 0 on master. Two
of them are this defect, both on amd_msan, WasmEdge, both with the same statement and the same
maximum: 9000 ms. The other three are unrelated and belong elsewhere (one
Code: 201 Quota for user default, two Code: 241 (total) memory limit exceeded under host
memory pressure).

Verification. Three arms with the same binary: as-is rc=0, pin removed rc=0, and as a live
control the pin forced to 0.001 rc=159 (Timeout exceeded: elapsed 2.543 ms, maximum: 1 ms),
which shows the guard is detectable and that only this token can produce this failure here. The
test then passes 1/1 through the harness and 50/50 with randomized settings, with no Code: 159.

I kept the rest of the blob untouched, including max_execution_speed = '1', which cannot fire
anyway because timeout_before_checking_execution_speed is 10 s by default and 300 s in the CI
profile.

Version info

  • Merged into: 26.8.1.305 (included in 26.8 and later)

The test pinned max_execution_time = '9' on a one-row
INSERT INTO data_a_02187 SELECT * FROM system.one. That setting is a
wall-clock deadline, not a work budget: it is registered per query in
ProcessList.cpp and enforced by a background thread in
CancellationChecker.cpp. On Stateless tests (amd_msan, WasmEdge) the
statement was descheduled past its own deadline under load and the test
failed with

  Code: 159. Timeout exceeded: elapsed 11056.432 ms, maximum: 9000 ms.

The failing job's server log shows the query logging its last pipeline
line, then nothing at all for 9.000839 s, then the cancellation, while
2396 lines from 120 other query ids land in the same window. Nothing in
the statement got slower.

Removing the pin does not weaken the test. It was added as a test for
issue ClickHouse#38729 (Block structure mismatch in Pipes stream), its reference
file is empty, it expects no server or client error, and EXPLAIN
PIPELINE of the statement is byte-identical with and without the token.
The test stays bounded by the harness --timeout of 600 s.

Raising the value again was not an option: PR ClickHouse#67867 already raised this
same pin from 3 to 9 for the same class of failure. Over the last 30
days this test file takes p50 2170 ms and p95 3210 ms on that flavour,
and 24 of 8051 passing runs already exceed 9000 ms for the whole file,
so no constant makes a per-statement 9 s cap reliable.

Verified with three arms on one binary: as-is rc=0, pin removed rc=0,
and as a live control the pin forced to 0.001 rc=159. The test then
passes 1/1 through the harness and 50/50 with randomized settings.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)

Two independent reviews ran against this diff: a cold read of the resulting tree by a reviewer
that did not write it, and a second-model gate review. Verdicts and evidence below.

Gate review: 0 findings. Coverage: the changed test, its reference file, the sibling
02524_fuzz_and_fuss, the file's history, the CI report, the test runner's timeout and result
paths, and the timeout registration, cancellation, default and speed-limit code.

Cold review: 2 findings, both nits in the pull request text, no code finding. Both are fixed
above.

Finding Verdict Resolution
💡 The residual-bound argument claimed the test stays flagged if it exceeds TEST_MAX_RUN_TIME_IN_SECONDS (180 s). That check is gated on test_runs > 1 and flaky_check (tests/clickhouse-test:3357-3361), and the failing job runs --test-runs 1, so the flag applies only inside the flaky check. ❌ agreed Text corrected to attribute the 180 s flag to the flaky check only.
💡 The residual upper bound was given as the harness --timeout (600 s). The tighter bound is client-side: ClientBase::receiveResult breaks on connection_parameters.timeouts.receive_timeout (ClientBase.cpp:1579), which is the client config default of 300 s and is not fed by the receive_timeout = '10' in this blob. ❌ agreed Text corrected to state both bounds, 300 s client-side and 600 s harness-side.

Carriers the cold review enumerated independently before comparing them against the fix plan,
because the statement demonstrably can take 11 s once the 9 s cap is gone:

  • max_execution_speed = '1' cannot fire. ExecutionSpeedLimits::throttle is gated on
    total_elapsed > timeout_before_checking_execution_speed, which is 10 s by default
    (Settings.cpp:3337) and 300 s in the CI profile (tests/config/users.d/limits.yaml:25), both
    above the removed 9 s, and the rps path only calls limitProgressingSpeed, which sleeps at
    most 1 s.
  • receive_timeout = '10' cannot fire either. Server-side it is reached only in
    TCPHandler::receivePacketsExpectData, and this statement never enters it:
    addInsertToSelectPipeline sets sinks and leaves no input port
    (InterpreterInsertQuery.cpp:539-544), so the pipeline is completed() rather than pushing()
    (QueryPipeline.h:99-103) and TCPHandler takes the completed branch. Client-side the wait is
    bounded by the 300 s config default, not by this setting.
  • The 9 s cannot come back from outside the file. max_execution_time does not appear in
    tests/clickhouse-test, the failing run's own 183-token randomized set does not contain it, and
    the only CI profile that sets it (limits_fast.yaml) is symlinked under is_fast_build
    (install.sh:274), so it is never installed on a sanitizer build. With the token gone the
    effective value is the documented default 0, and CancellationChecker::appendTask returns
    early for a non-positive timeout (:85-89), so no deadline task is registered at all.
  • Scope is one file. No other stateless test carries a quoted max_execution_time = '<int>'
    fuzzer-blob pin, max_execution_speed = '1' exists in exactly one stateless test, and the only
    other user of data_a_02187 (02187_insert_values_with_mv.sql) is untouched.

The cold review also confirmed the verification catch recorded by the implementation: run
literally, the planned EXPLAIN PIPELINE comparison is vacuous, because the pre-existing
max_result_rows = '10' truncates the EXPLAIN output itself and both sides return only
Code: 396. The strengthened form raises that limit in a probe copy that is not shipped, and both
sides then emit the same 39-line graph.

Numbers in the description were re-derived against the CI database in the review session and
match: 5 failures over 60 days across 5 pull requests and 0 on master, of which exactly the two
amd_msan, WasmEdge rows carry TIMEOUT_EXCEEDED, maximum: 9000 ms and this statement; and
over 30 days of passing runs the file takes p50 2170 ms / p95 3210 ms on that flavour with 24 runs
already over 9000 ms.

Session id: cron:clickhouse-review-slot-8:20260728-091700

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes for the mechanism. The CI red itself is a host-load race and is deliberately not chased (the harness re-ran it 26/26 green with identical randomized settings). The on-demand repro is the control arm: the same test with the pin forced to 0.001 returns Code: 159 every time, i.e. this test fails deterministically the moment its wall-clock budget is shorter than the host makes the statement take.
b Root cause explained? Yes. max_execution_time is a wall-clock deadline registered per query in ProcessList.cpp:381 and enforced by a background thread (CancellationChecker.cpp:37-44). In the failing job's server log the query logs its last pipeline line at 15:49:36.864398, then nothing for 9.000839 s, then CancellationChecker: Cancelling the task because of the timeout: 9000 ms, while 2396 lines from 120 other query ids land in the same window. A one-row INSERT ... SELECT * FROM system.one was descheduled past its own deadline.
c Fix matches root cause? Yes. The root cause is the wall-clock deadline itself, so it is removed rather than re-tuned. No bound was widened, no no-random-* tag added, no dataset shrunk, no flavour skipped. #67867 already raised this pin from 3 to 9 for the same class, so another constant would be the third value for one defect.
d Test intent preserved / new tests added? Yes. The intent is the #38729 block-structure-mismatch assertion: the .reference is empty, there is no serverError/clientError expectation, EXPLAIN PIPELINE is byte-identical with and without the token, and every other limit in the blob is kept. No regression test is owed: no source changed, and a deletion in a test file adds no assertion to mutate.
e Both directions demonstrated? Yes. Three arms on one binary: as-is rc=0, pin removed rc=0, and the live control with the pin at 0.001 rc=159 (Timeout exceeded: elapsed 2.543 ms, maximum: 1 ms). The control is what proves the instrument detects a firing deadline. Post-fix the test passes 1/1 through the harness and 50/50 with randomized settings, with zero Code: 159.
f Fix is general across code paths? N/A for code paths (no source change). The analogous sweep is siblings: every stateless test pinning max_execution_time was reviewed; the short pins are load-bearing timeout assertions (clearest contrast, 03223_analyzer_with_cube_fuzz.sql:26, whose max_execution_time = 1. line ends -- { serverError TIMEOUT_EXCEEDED, QUERY_WAS_CANCELLED }) and are left alone. Three defensive-looking neighbours were measured over 60 days and have 0 TIMEOUT_EXCEEDED sightings, so they are out of scope rather than assumed clean.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A: a test-only setting removal, no types, wrappers or parameter matrix involved. The one input-shaped question, whether another setting in the same blob can now produce the same red, is answered in row (i).
h Backward compatible? (maintainer-approved exception only) Yes / N/A. Test-only change. No setting default moves, so SettingsChangesHistory.cpp is not involved, and there is no format or protocol change.
i Invariants and contracts preserved? Yes. No function contract changes. The other timeout carriers in the same blob cannot take over the failure: receive_timeout = '10' is a socket timeout, and server-side it is reached only in TCPHandler::receivePacketsExpectData, which this statement never enters: addInsertToSelectPipeline sets sinks and leaves no input port, so the pipeline is completed() rather than pushing() and TCPHandler takes the completed branch. Client-side the wait is bounded by connection_parameters.timeouts.receive_timeout (ClientBase.cpp:1579), which is the client config default of 300 s and is not fed by the query's SETTINGS. max_execution_speed = '1' is inert because timeout_before_checking_execution_speed is 10 s by default and 300 s in the CI profile, both above the removed 9 s. The 9 s cannot be reintroduced from outside the file: the setting is not randomized by clickhouse-test (the failing run's own 183-token randomized set does not contain it), and the only CI profile that sets it is gated on is_fast_build and so never installed on a sanitizer build. Post-fix the effective value is the documented default 0, measured, so no deadline task is registered at all; the residual bounds are the client's 300 s and clickhouse-test --timeout at 600 s.

Session id: cron:clickhouse-impl-slot-46:20260728-083300

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @vdimir — could you review this? It removes max_execution_time = '9' from the settings blob of 02524_fuzz_and_fuss_2: that pin is a wall-clock deadline on a one-row INSERT ... SELECT * FROM system.one, and on the msan WasmEdge runner the statement gets descheduled past it under load, so the test fails with TIMEOUT_EXCEEDED at 11 s. The pin is defensive rather than load-bearing (empty reference file, no error expectation, identical EXPLAIN PIPELINE), and #67867 already raised it from 3 to 9 for this same class.

@Algunenano Algunenano self-assigned this Jul 28, 2026
@Algunenano Algunenano added the can be tested Allows running workflows for external contributors label Jul 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b189619]

Summary: ✅


AI Review

Summary

This PR removes the scheduler-sensitive max_execution_time = '9' pin from 02524_fuzz_and_fuss_2 so the test no longer fails with a CI-only wall-clock timeout on overloaded amd_msan, WasmEdge runners. The changed file, empty .reference, surrounding timeout-based tests, and fully green CI all support the stated contract: the test still exercises the original block-structure-mismatch path and I did not find a correctness or coverage regression.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 28, 2026
@Algunenano
Algunenano enabled auto-merge July 28, 2026 16:18
@Algunenano
Algunenano added this pull request to the merge queue Jul 28, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — b189619

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
(none) 174 check-runs, 0 failures nothing to own

Config Workflow and Finish Workflow both completed successfully; no check queued or in progress.

Session id: cron:our-pr-ci-monitor:20260728-183000

Merged via the queue into ClickHouse:master with commit 4c875b2 Jul 28, 2026
178 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants