Skip to content

Do not report "Server died" when a test run hits the global time limit - #106183

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix-timeout-not-server-died
Jun 2, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
fix-timeout-not-server-died

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 31, 2026 •

Copy link
Copy Markdown
Member

The flaky and targeted stateless checks deliberately rerun the selected tests until their time budget is exhausted (rerun_count = 50, so the global time limit is the intended stop condition, not the repeat count). However, clickhouse-test raised StopTesting for five unrelated reasons — server died, hung check, --max-failures, and the global time limit — all exiting with the same STOP_TESTING_EXIT_CODE, which the job side mapped unconditionally to a synthetic Server died leaf. A clean, expected timeout was therefore indistinguishable from a real crash and reported as Server died.

This change gives the graceful time-limit stop a distinct GLOBAL_TIME_LIMIT_EXIT_CODE and reports it as a benign Global time limit reached result instead of Server died. The time budget is now handed to clickhouse-test via --global_time_limit so it stops gracefully between tests; the external Shell.run timeout is kept only as a larger safety net for a genuinely frozen process.

To keep the graceful exit code from being clobbered into 143 (which is treated as Server died) by the killpg feedback loop in stop_tests, parallel workers now stop quietly on the deadline and the parent ignores SIGTERM while terminating them. Genuine server deaths and --max-failures aborts keep precedence over the time-limit path.

Example of a targeted check mislabeled as Server died on timeout (and corresponding PR #105943):
https://s3.amazonaws.com/clickhouse-test-reports/PRs/105943/9a0a506d1908116e6fc0532eff6a1c126b5cbcfb/stateless_tests_arm_asan_ubsan_targeted/job.log
#105943

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):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

Version info

  • Merged into: 26.6.1.310

The flaky and targeted stateless checks deliberately rerun the selected
tests until their time budget is exhausted (`rerun_count = 50`, so the
time limit is the intended stop condition). `clickhouse-test` raised
`StopTesting` for five unrelated reasons - server died, hung check,
`--max-failures`, and the global time limit - all exiting with the same
`STOP_TESTING_EXIT_CODE`, which the job side mapped unconditionally to a
synthetic "Server died" leaf. A clean, expected timeout was therefore
indistinguishable from a real crash.

Give the graceful time-limit stop a distinct `GLOBAL_TIME_LIMIT_EXIT_CODE`
and report it as a benign "Global time limit reached" result rather than
"Server died". Hand the budget to `clickhouse-test` via `--global_time_limit`
so it stops gracefully between tests; keep the external `Shell.run` timeout
only as a larger safety net for a genuinely frozen process.

To keep the graceful exit code from being clobbered into 143 ("Server
died") by the `killpg` feedback loop in `stop_tests`, parallel workers
now stop quietly on the deadline and the parent ignores `SIGTERM` while
terminating them.

Example of a targeted check mislabeled as "Server died" on timeout:
https://s3.amazonaws.com/clickhouse-test-reports/PRs/105943/9a0a506d1908116e6fc0532eff6a1c126b5cbcfb/stateless_tests_arm_asan_ubsan_targeted/job.log

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4d2250a]

Summary: ✅


AI Review

Summary

This PR separates the expected functional-test global timeout from real runner aborts by passing --global_time_limit into clickhouse-test and mapping GLOBAL_TIME_LIMIT_EXIT_CODE to a benign Global time limit reached result. The widened outer timeout fixes the earlier hard-kill pre-emption concern, but one failure-precedence issue remains in the parent runner loop.

Findings

⚠️ Majors

  • [tests/clickhouse-test:4961] clickhouse-test promises that real hung/server failures keep precedence over the benign global-time-limit path, but the parent sets global_time_limit_reached before running the --hung-check liveness probe in the same loop iteration. If the server is already unresponsive when args.stop_time is crossed, the following hung check can observe and print the failure, yet line 5001 still raises StopTesting with GLOBAL_TIME_LIMIT_EXIT_CODE, so FTResultsProcessor reports an OK Global time limit reached leaf instead of a failed server-not-responding run. Run the liveness check before claiming the global timeout, or clear the benign flag when the hung check fires.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: preserve hung-check/server-not-responding failure precedence when the global deadline and parent liveness probe happen in the same polling iteration.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 31, 2026
Comment thread ci/jobs/functional_tests.py Resolved
Comment thread tests/clickhouse-test Resolved
@CheSema CheSema self-assigned this May 31, 2026
alexey-milovidov and others added 2 commits June 1, 2026 09:45
The external `Shell.run` safety-net timeout was `global_time_limit + 600`,
but a test that starts just before the global deadline can still be inside
its own per-test alarm window, which `clickhouse-test` arms as
`int(args.timeout * 1.1) + 60` (720s with the default `--timeout 600`).
With only a 600s margin the external `SIGTERM` could fire before the
graceful per-test stop, returning `143` and reporting `Server died` -
exactly the misclassification this PR removes.

Widen the margin to 900s so it exceeds the per-test bound plus the worker
shutdown wind-down, leaving the external kill for a genuinely frozen process.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread tests/clickhouse-test
# distinct from a server death or a hung check below. Only claim the
# time limit if nothing else has already requested a stop, so a real
# server death or `--max-failures` abort keeps precedence.
if (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global_time_limit_reached is set before the parent runs the --hung-check liveness probe below, and the later if global_time_limit_reached branch forces GLOBAL_TIME_LIMIT_EXIT_CODE. If the server becomes unresponsive in the same polling iteration that crosses args.stop_time, this branch claims the benign timeout first; the immediately following hung check can still print Hung check failed and set stop_testing, but the final exit remains 3, so FTResultsProcessor reports an OK Global time limit reached leaf instead of a failed server-not-responding run. The PR says real hung/server failures keep precedence, so please run the liveness check before claiming the global timeout or clear the benign flag when the hung check fires.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for now.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 2, 2026
Merged via the queue into master with commit 5a647dc Jun 2, 2026
166 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-timeout-not-server-died branch June 2, 2026 05:07
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 2, 2026
@groeneai groeneai mentioned this pull request Jun 23, 2026
1 task done
pull Bot pushed a commit to Spencerx/ClickHouse that referenced this pull request Aug 5, 2026
This parametrization is being killed at the shared 9000s functional-test timeout
with tests still unrun, so the job reports error with no failing test and the
author sees an unattributable red. Over the 7 days to 2026-08-04 there were 16
such kills, all in a 25s band at 9016-9041s, hitting master twice and 14 PRs by
10 authors, 12 of them from other contributors. The prior 7 days had 5, so the
rate is rising.

The cause is per-shard volume, not a hang and not one slow test. Successful-run
p50 wall time on the slower of the two shards grew from about 5300s (2026-07-04)
to about 6800s (2026-08-04). A least-squares fit over those 32 daily p50 values
gives about +51s/day, leaving roughly six weeks of headroom on p50 and two on
p99 against the cap.

Wall time responds to sharding. Fitting wall time against summed per-test time
over 1671 successful runs gives wall_s = 255 + 0.08979 * sum_test_s with
r = 0.9722, so effective concurrency is about 11x and only about 255s is
unshardable setup and teardown. Back-substituting the measured per-shard
test-seconds reproduces the measured wall times to within 0.8%. Projected at 3
batches, using the measured crc32 bucket shares, the worst shard lands at a p50
of about 4671s (52% of the cap) and its growth slope falls to about 35s/day.

I raised the batch count rather than the timeout: a larger budget lets a genuine
hang burn hours, against the fail-fast intent of ClickHouse#106183 and ClickHouse#107602, and it
treats the cap instead of the volume. No new mechanism is introduced.
Job.ParamSet already emits {batch}/{total_batches} into the job name and
ci/jobs/functional_tests.py already forwards --run-by-hash-total and
--run-by-hash-num to clickhouse-test. Precedent: ClickHouse#108970 split
amd_llvm_coverage the same way, and amd_tsan, s3 storage, parallel already
uses 3.

The sequential sibling is deliberately left alone: it had 0 runs above 8000s in
the same window (p50 5555/6201), so splitting it would spend runners on a
problem that does not exist.

Partition integrity was verified over all 13230 selectable files in
tests/queries/0_stateless using the same crc32(filename) % total predicate as
tests/clickhouse-test: 6596 + 6634 at 2 batches, 4461 + 4417 + 4352 at 3. Both
sum to 13230 with the union equal to the full set, so no test is lost or
duplicated. The no-batch tag is used by 0 test files.

The workflow YAML is generated, not hand-edited. Note that praktika yaml runs
git add on its output, so a bare git diff reads clean while the generated files
have changed; scope must be checked with git diff HEAD.

Closes: ClickHouse#113164
pull Bot pushed a commit to peijunlin2008/ClickHouse that referenced this pull request Sep 27, 2026
`ABORTED_RUN_EXIT_CODES` synthesizes a "Server died" FAIL leaf for any
death-by-signal of the test command, so a run that was killed externally
is reported as a server crash even when nothing observed one.

On PR ClickHouse#108676 / Stateless tests (amd_tsan, parallel) the report read
"Failed: 0, Passed: 10564, Skipped: 171" with "Server died" as the only
failure: three tests completed [ OK ] in the final two seconds before the
kill, the server then answered "system flush logs" and stopped cleanly
under --do-not-kill, and the job log had zero <Fatal>, zero "Received
signal" and a clean dmesg. Measured over 30 days, 53 stateless and fast
test jobs across 49 PRs carry that leaf with no other failing row.

The exit code establishes only that the run was killed, never by whom, so
when the parser observed no failure at all the honest verdict is that the
cause could not be attributed. Report ERROR with a leaf naming what was
actually observed instead of asserting a cause. The job stays red either
way (neither FAIL nor ERROR is in `Result.is_ok`), so for a normal job
this only changes the wording.

ERROR rather than FAIL because `invert_bugfix_validation_status` flips any
FAIL row to OK without inspecting its name, which would turn an exit code
into a claimed bug reproduction. ERROR is the existing inconclusive
channel, and `reconcile_bugfix_crash_repro` still downgrades ERROR to FAIL
when a BLOCKER fatal is present, so a genuine crash keeps validating
(ClickHouse#105789).

The gate reads the summary counters rather than filtering rows through
`is_failure()`: a [ NOT_FAILED ] row increments `failed` but is stored with
a status string that `is_failure()` does not match, so filtering rows would
reclassify a run whose failure was reported.

`STOP_TESTING_EXIT_CODE` is deliberately excluded, since the parent raising
`StopTesting` did observe a reason to stop.

Related: ClickHouse#106183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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