Skip to content

CI: do not report "Server died" when a run stops on --max-failures - #107602

Merged
Algunenano merged 2 commits into
ClickHouse:masterfrom
Algunenano:fix-flaky-check-mislabel
Jun 16, 2026
Merged

Algunenano merged 2 commits into
ClickHouse:masterfrom
Algunenano:fix-flaky-check-mislabel

Conversation

@Algunenano

@Algunenano Algunenano commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

The "Stateless tests (flaky check)" job reports "Server died" and demotes every failing test to UNKNOWN whenever a run stops on --max-failures, even though the server is perfectly alive. clickhouse-test raised StopTesting with the default STOP_TESTING_EXIT_CODE (2) — the same code used for a real server death — so the job side could not tell the two apart and hid which test actually failed.

This gives the --max-failures / --max-failures-chain stop its own exit code (MAX_FAILURES_EXIT_CODE = 4), distinct from server death and the global time limit. The job now reports it as "Too many test failures" and keeps the failing tests as FAIL (real, already-attributed failures) instead of demoting them to UNKNOWN and synthesizing a "Server died" leaf.

It also fixes the HTML report ordering: getStatusPriority in ci/praktika/json.html had no branch for UNKNOWN, so UNKNOWN rows sorted below all the OK rows (fail > ok > unknown). UNKNOWN now ranks right under the errors and failures, so rows whose real result was lost are visible at the top.

Example report where the mislabel is visible — a single failing test (deltaLakeLocal is not built with MSan) shown as a generic "Server died" plus five UNKNOWN reruns: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107341&sha=49c86b80ca9c46024be1ec61a1c3ba97a45544b8&name_0=PR&name_1=Stateless+tests+%28amd_msan%2C+flaky+check%29&name_2=Tests

Related: #107341

cc @leshikus

Changelog category (leave one):

  • CI Fix or Improvement

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

Not for changelog (CI only).

Version info

  • Merged into: 26.6.1.882

…ix UNKNOWN ordering

The flaky check runs with `--max-failures 5`. When a test legitimately failed
five times, `clickhouse-test` raised `StopTesting` with the default
`STOP_TESTING_EXIT_CODE` (2) - the same code used when the server actually dies.
The job side (`functional_tests_results.py`) then reported a generic "Server
died" leaf and demoted every real failure to `UNKNOWN`, hiding which test
actually failed even though the server was perfectly alive.

Give the `--max-failures` / `--max-failures-chain` stop its own exit code
(`MAX_FAILURES_EXIT_CODE = 4`), distinct from server death and the global time
limit. The parent detects the max-failures stop (shared failure counter) and
re-raises with the new code; the worker-side raises carry it for sequential
runs. The job side reports it as "Too many test failures" and keeps the failing
tests as FAIL (real, already-attributed failures) instead of demoting them.

Also fix the HTML report ordering: `getStatusPriority` in `json.html` had no
branch for UNKNOWN, so it fell through to the lowest priority and sorted below
all the OK rows (fail > ok > unknown). Rank UNKNOWN right under the errors and
failures so the rows whose real result was lost are visible at the top.

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

clickhouse-gh Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [52096ed]

Summary: ✅


AI Review

Summary

This PR separates --max-failures / --max-failures-chain stops from Server died stops in clickhouse-test, keeps real failures attributed in FTResultsProcessor, and raises UNKNOWN rows in report sorting. I found no remaining correctness or safety issues in the current diff; the prior bot thread about chain-limit propagation is resolved by the shared stop_exit_code.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 16, 2026
Comment thread tests/clickhouse-test Resolved
In a parallel run the worker that reaches `--max-failures` or
`--max-failures-chain` raises `StopTesting` with `MAX_FAILURES_EXIT_CODE`
inside its own process, so that exception never reaches the parent. The
parent reconstructed the code only from the shared total-failure counter,
so the `--max-failures-chain` path (and `--max-failures 0`) fell through.

Worse, reproducing it shows both parallel paths exited 143, not the default
2: the worker's `stop_tests()` does `killpg(SIGTERM)` over the whole process
group, killing the parent before it can re-raise with the right code. 143
(`128 + SIGTERM`) is an aborted-run code, so the job side still reported
"Server died" and demoted the real failures to `UNKNOWN`. The global time
limit path avoids this because the parent initiates it and masks SIGTERM
first.

Fix:
- Carry the worker's intended exit code to the parent through a shared
  `stop_exit_code` value (set before `stop_testing`); the parent re-raises
  with it. This covers both `--max-failures` and `--max-failures-chain`.
- The max-failures / chain raises no longer call `stop_tests()`, so they do
  not SIGTERM the parent. The parent masks SIGTERM and terminates the workers
  in an orderly way, exactly like the time limit path. Server death keeps
  `stop_tests()` (still reported as "Server died").
- A sibling worker that only observes `stop_testing` now breaks quietly when
  concurrent instead of calling `stop_tests()`, mirroring the time limit
  handling.

Add focused coverage in `ci/tests`: a unit test that `MAX_FAILURES_EXIT_CODE`
maps to a "Too many test failures" leaf and keeps the failures as `FAIL`
(contrasted with the aborted-run code that demotes to `UNKNOWN`), and an
end-to-end test that a parallel run exits with `MAX_FAILURES_EXIT_CODE` for
both the chain-limit and total-limit paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@leshikus
leshikus self-requested a review June 16, 2026 12:37

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good

@Algunenano
Algunenano enabled auto-merge June 16, 2026 12:45
@Algunenano
Algunenano disabled auto-merge June 16, 2026 13:26
@Algunenano
Algunenano enabled auto-merge June 16, 2026 13:35
@Algunenano
Algunenano added this pull request to the merge queue Jun 16, 2026
Merged via the queue into ClickHouse:master with commit bb53b35 Jun 16, 2026
166 checks passed
@Algunenano
Algunenano deleted the fix-flaky-check-mislabel branch June 16, 2026 17:23
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 16, 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
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