Repository navigation
Treat SIGTERM/SIGKILL kill codes as aborted run in functional-test parser - #105643
Conversation
…rser Follow-up to PR ClickHouse#105298 (commit fc45ec9) which introduced `STOP_TESTING_EXIT_CODE = 2` as the stable signal from `clickhouse-test` to the job-side parser for "the run was aborted mid-flight (server died, hung-check tripped, etc.)". The parser uses that signal to attach a synthetic `Server died` leaf and demote ambiguous per-test failures to `UNKNOWN`. The contract holds when `clickhouse-test` reaches `sys.exit(STOP_TESTING_EXIT_CODE)` through the `except StopTesting` handler. It does *not* hold in the parent-side hung-check path, which is the most common abort scenario: when the parent terminates a worker via `p.terminate()`, the worker's `signal_handler` raises `Terminated` (subclass of `KeyboardInterrupt`), `run_tests_array`'s `except KeyboardInterrupt` calls `stop_tests()`, which `killpg`s the entire process group - hitting the parent before it can exit through `StopTesting`. The parent's own `signal_handler` then raises `Terminated` and `__main__` exits `128 + SIGTERM = 143`. Concrete failure mode on PR ClickHouse#105041 (https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105041&sha=68cd608314c8187b7813ab0317a528ec6aff3409&name_0=PR&name_1=Bugfix%20validation%20%28functional%20tests%29): master hung running the PR's new tests, `clickhouse-test` was killed with exit code 143, no per-test result lines reached `test_result.txt`, the parser fell through to `not s.success_finish` (state = `ERROR`, `results = []`), and the bugfix-validation inverter then overwrote that honest ERROR with `set_failed().set_info("Failed to reproduce the bug")` - exactly the opposite of what happened. Replace the singleton `runner_exit_code == STOP_TESTING_EXIT_CODE` check with a `frozenset` that also matches `128 + SIGTERM` (143) and `128 + SIGKILL` (137). All three carry the same semantics: the run was aborted mid-flight, partial per-test results are incomplete, the `Server died` leaf is appropriate. Exit code 1 is deliberately *not* in the set. It is set by end-of-run post-checks (final hung-check, `runner_process_killed`, `total_tests_run == 0`) that run after every test has finished - per-test results are authoritative in that case and must not be demoted. The existing tail handler at the bottom of `FTResultsProcessor.run` already handles exit 1 by appending a generic `clickhouse-test exited with code N` leaf without touching per-test results. This commit does not fix the underlying `worker -> parent` SIGTERM feedback loop in `tests/clickhouse-test`. That root-cause fix (mask SIGTERM on the parent during the worker-cleanup block, or stop `Terminated` from triggering `stop_tests` in workers) is left for a separate change. Adding the kill codes here is defence-in-depth that makes the parser robust to the loop without depending on whether it ever gets fixed - and also covers external kills (job-level timeout, runner shutdown) which would otherwise fall through to the same incorrect ERROR path. A second bug surfaced by the same CI report - the bugfix-validation inverter overwriting `status=ERROR` with `set_failed("Failed to reproduce the bug")` when `test_result.results` is empty - is a separate change. ### Changelog category (leave one): - CI Fix or Improvement (changelog entry is not required) ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): ... ### Documentation entry for user-facing changes - [ ] Documentation is written (mandatory for new features)
|
Workflow [PR], commit [07778ae] Summary: ✅ AI ReviewSummaryThis PR hardens functional-test result classification by treating Final VerdictStatus: ✅ Approve |
`Shell.run` wraps the command in `bash -c` and tracks the wrapper via `subprocess.Popen`. When `Shell._check_timeout` calls `os.killpg(proc.pid, SIGTERM/SIGKILL)`, the wrapper bash can itself die from the signal — in which case Python's `Popen.returncode` is the negative form `-N`, not bash's `128 + N`. The realistic main case is SIGKILL escalation after the 100s grace period (also reachable via the kernel OOM killer or the GitHub Actions runner force-kill on job-level timeout). Without the negative variants the kill path falls through to `not s.success_finish` (ERROR) instead of the aborted-run path, defeating the point of the previous commit. Add `-SIGTERM` (-15) and `-SIGKILL` (-9) to `ABORTED_RUN_EXIT_CODES`.
…e#105789) The bugfix-validation inverter in `ci/jobs/functional_tests.py` flipped per-test `FAIL`/`OK` so that a regression test for a bug, which is expected to `FAIL` on master HEAD, is reported as "bug reproduced". When the run itself ended in `Result.Status.ERROR` (server crashed and the runner could not finish, runner Python exception, job-level timeout, infrastructure outage), `test_result.results` was empty or partial; the inverter loop ran zero times, `has_failure` stayed `False`, and the `else` branch unconditionally called `set_failed().set_info("Failed to reproduce the bug")`. The honest `ERROR` was silently overwritten with a misleading "the regression test does not catch the bug" `FAIL`. Extract the inverter to a standalone module-level helper `invert_bugfix_validation_status` and short-circuit when `test_result.status == Result.Status.ERROR`: preserve the original `ERROR` and its `info` instead of overwriting them. Leaves still get the `XFAIL` label so the `json.html` view renders them consistently. The complementary `Server died` synthesis (for `runner_exit_code in {STOP_TESTING_EXIT_CODE, 137, 143}`) lives in PR ClickHouse#105643 by @leshikus. With that PR, signal-killed runs surface a `FAIL` leaf that the inverter correctly maps to "bug reproduced". This change covers all other paths that leave `test_result.status == ERROR` (Python exceptions, non-SIGTERM job timeouts, infra outages) so they no longer report a spurious "Failed to reproduce the bug". Tests: `ci/tests/test_bugfix_validation_inverter.py` covers the four intended paths (single FAIL, single OK, mixed, synthetic Server died leaf), the two ERROR-preservation paths (empty results, partial OK results), the XFAIL labelling invariant, and the empty-OK fallback. Reproduced the original buggy behaviour against an inlined copy of the pre-fix code path to confirm both directions.
|
It would be nice if this PR were finished, since the bugfix validation check doesn't work on master right now. |
|
@novikd the pr still lacks an approval - I cannot commit it; can I do anything to get an approval from you? |
|
@maxknv we discussed the patch with Dima and agreed that it would be good if you could also take a look at it; |
db6d7a5
|
This is now causing hundreds of "Server died" failures that aren't such. For example due in targeted-budget timeouts: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105019&sha=latest&name_0=PR&name_1=Stateless+tests+%28arm_asan_ubsan%2C+targeted%29 |
|
@Algunenano yes, we need to distinguish "Server died" and "clickhouse-test error"; I will prepare a patch |
|
Please have a look #106228. Feel free to disregard it or adopt it or accept it |
Master's `invert_bugfix_validation_status` (picked up by the master-merge) gates only on top-level `Result.Status.ERROR`. The sequential 'server died' path in `functional_tests_results.py` marks the culprit test `ERROR` and appends a 'Server died' `FAIL` leaf, leaving the top-level status `FAIL` — so the top-level-only gate would flip that `FAIL` to `OK` + `set_success` and count a false validation. Extend the gate to `test_result.is_error() or any(r.is_error() ...)`, mirroring the `had_infra_or_error` guard in `integration_test_job.py`. A synthetic 'Server died' `FAIL` leaf with no `ERROR` sub-result (a crash-bug regression test whose bug IS the crash, per ClickHouse#105643) has no `ERROR` sub-result and is still correctly counted as reproduced. This restores the five-scenario correctness verified in the reverted `ef0816c88eb` while keeping the inversion in the shared function rather than an inline duplicate. Adds a regression test for the coexisting ERROR+FAIL case. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Master's `invert_bugfix_validation_status` (picked up by the master-merge) gates only on top-level `Result.Status.ERROR`. The sequential 'server died' path in `functional_tests_results.py` marks the culprit test `ERROR` and appends a 'Server died' `FAIL` leaf, leaving the top-level status `FAIL` — so the top-level-only gate would flip that `FAIL` to `OK` + `set_success` and count a false validation. Extend the gate to `test_result.is_error() or any(r.is_error() ...)`, mirroring the `had_infra_or_error` guard in `integration_test_job.py`. A synthetic 'Server died' `FAIL` leaf with no `ERROR` sub-result (a crash-bug regression test whose bug IS the crash, per ClickHouse#105643) has no `ERROR` sub-result and is still correctly counted as reproduced. This restores the five-scenario correctness verified in the reverted `ef0816c88eb` while keeping the inversion in the shared function rather than an inline duplicate. Adds a regression test for the coexisting ERROR+FAIL case. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Motivation
Follow-up to PR #105298 (commit fc45ec9) which introduced
STOP_TESTING_EXIT_CODE = 2as the stable signal fromclickhouse-testto the job-side parser for "the run was aborted mid-flight (server died,
hung-check tripped, etc.)". The parser uses that signal to attach a
synthetic
Server diedleaf and demote ambiguous per-test failures toUNKNOWN.The contract holds when
clickhouse-testreachessys.exit(STOP_TESTING_EXIT_CODE)through the
except StopTestinghandler. It does not hold in theparent-side hung-check path, which is the most common abort scenario:
when the parent terminates a worker via
p.terminate(), the worker'ssignal_handlerraisesTerminated(subclass ofKeyboardInterrupt),run_tests_array'sexcept KeyboardInterruptcallsstop_tests,which
killpgs the entire process group - hitting the parent before itcan exit through
StopTesting. The parent's ownsignal_handlerthenraises
Terminatedand__main__exits128 + SIGTERM = 143.Concrete failure mode
On PR #105041, bugfix validation report:
master hung running the PR's new tests,
clickhouse-testwas killedwith exit code 143, no per-test result lines reached
test_result.txt,the parser fell through to
not s.success_finish(state =ERROR,results = []), and the bugfix-validation inverter then overwrote thathonest ERROR with
set_failed().set_info("Failed to reproduce the bug")-exactly the opposite of what actually happened (the server died on
master, so the bug was reproduced, just more catastrophically than
the test expected).
Change
Replace the singleton
runner_exit_code == STOP_TESTING_EXIT_CODEcheckwith a
frozensetthat also matches128 + SIGTERM(143) and128 + SIGKILL(137). All three carry the same semantics: the run wasaborted mid-flight, partial per-test results are incomplete, the
Server diedleaf is appropriate.Exit code 1 is deliberately not in the set. It is set by end-of-run
post-checks (final hung-check,
runner_process_killed,total_tests_run == 0) that run after every test has finished -per-test results are authoritative in that case and must not be demoted.
The existing tail handler at the bottom of
FTResultsProcessor.runalready handles exit 1 by appending a generic
clickhouse-test exited with code Nleaf without touching per-test results.What this does not fix
This commit does not fix the underlying
worker -> parentSIGTERMfeedback loop in
tests/clickhouse-test. That root-cause fix (maskSIGTERM on the parent during the worker-cleanup block, or stop
Terminatedfrom triggeringstop_testsin workers) is left for aseparate change. Adding the kill codes here is defence-in-depth that
makes the parser robust to the loop without depending on whether it
ever gets fixed - and also covers external kills (job-level timeout,
runner shutdown) which would otherwise fall through to the same
incorrect ERROR path.
A second bug surfaced by the same CI report - the bugfix-validation
inverter overwriting
status=ERRORwithset_failed("Failed to reproduce the bug")whentest_result.resultsis empty - is also aseparate change.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.6.1.242