Skip to content

CI: fix Bugfix validation after stop-testing rename - #105298

Merged
leshikus merged 2 commits into
ClickHouse:masterfrom
leshikus:fix-server-died-sign-104081
May 19, 2026
Merged

leshikus merged 2 commits into
ClickHouse:masterfrom
leshikus:fix-server-died-sign-104081

Conversation

@leshikus

@leshikus leshikus commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

#104081 renamed the server_died event to stop_testing in clickhouse-test and replaced the parent-side print

Server died, terminating all processes...

with

Stopping tests, terminating all processes...

The functional-tests results parser in ci/jobs/scripts/functional_tests_results.py still searched for the old string, so when a Bugfix validation run actually killed the server it never emitted the synthetic Server died leaf that the inversion step in ci/jobs/functional_tests.py flips to OK — and the job reported Failed to reproduce the bug even though the bug had reproduced.

This PR realigns the two SIGN constants to the wording the runner now emits and renames the carried variable / Summary field to stop_testing to match.

Observed on the Bugfix validation (functional tests) job of #105286 (server crashed under the test; log line Stopping tests, terminating all processes...).

Refs #104081.

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

...

Version info

  • Merged into: 26.5.1.856

ClickHouse#104081 renamed the `server_died` event to `stop_testing` in
`clickhouse-test` and replaced the parent-side print
`Server died, terminating all processes...` with
`Stopping tests, terminating all processes...`. The functional-tests
results parser still searched for the old string, so when a Bugfix
validation run actually killed the server it failed to emit the
synthetic `Server died` leaf that the inversion step in
`ci/jobs/functional_tests.py` flips to OK — and the job reported
`Failed to reproduce the bug` even though the bug had reproduced.

Realign the two SIGN constants to the wording the runner now emits
and rename the carried variable/field to `stop_testing` to match.

Observed on the `Bugfix validation (functional tests)` job of
ClickHouse#105286
(server crashed under the test, log: `Stopping tests, terminating all processes...`).

Refs ClickHouse#104081
@clickhouse-gh

clickhouse-gh Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bfb9a67]

Summary: ✅


AI Review

Summary

This PR updates ci/jobs/scripts/functional_tests_results.py to track the renamed stop-testing signal from clickhouse-test while still matching the health-check failure message, restoring correct bugfix-validation inversion behavior. I reviewed the current diff, surrounding call paths, and prior review threads; there are no unresolved correctness, safety, or metadata issues.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 19, 2026
@leshikus
leshikus requested a review from maxknv May 19, 2026 10:08
@leshikus
leshikus marked this pull request as ready for review May 19, 2026 10:09
HUNG_SIGN = "Found hung queries in processlist"
SERVER_DIED_SIGN = "Server died, terminating all processes"
SERVER_DIED_SIGN2 = "Server does not respond to health check"
STOP_TESTING_SIGN = "Stopping tests, terminating all processes"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should put this in a common file and use them in clickhouse-test. Otherwise this will happen again

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

And also this looks fragile, maybe we need to use constants from clickhouse-test directly here?

Also can't bugfix simply consider any error as the bug is reproduced?

@leshikus leshikus May 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I will fix this with the next PR. Let me know what do you think is better - having a clear automation marker in the report text, e.g. STOP_TESTING or ###STOP_TESTING###; or maybe just using exit code 2 for clickhouse-test to signal this situation. @azat @Algunenano

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The point why I want to commit this now is this affects some of CI checks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

exit code 2 for clickhouse-test to signal this situation

I like this one

Another option is to add proper reports into clickhouse-test that will be more or standardized and will not require that complex parsing

@Algunenano Algunenano self-assigned this May 19, 2026
@leshikus
leshikus added this pull request to the merge queue May 19, 2026
Merged via the queue into ClickHouse:master with commit f5954da May 19, 2026
165 checks passed
@leshikus
leshikus deleted the fix-server-died-sign-104081 branch May 19, 2026 18:53
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 19, 2026
pull Bot pushed a commit to Mu-L/ClickHouse that referenced this pull request May 20, 2026
Follow-up to PR ClickHouse#105298 (ClickHouse#105298 (comment))
and PR ClickHouse#104081 (ClickHouse#104081).

Previously the job-side parser detected the stop_testing condition (server
died, hung check failed, --max-failures reached, etc.) by matching specific
strings in `test_result.txt`. Every wording change in `clickhouse-test`
risked silently breaking bugfix validation - exactly what happened when
PR ClickHouse#104081 renamed `Server died, terminating all processes...` to
`Stopping tests, terminating all processes...`.

Replace that fragile log-line matching with a stable contract: an exit
code. `clickhouse-test` now exits with `STOP_TESTING_EXIT_CODE = 2` when
the run is aborted via a new `StopTesting` exception (renamed from
`TestRunAbort`, mirroring `StopIteration`). All paths that previously set
the `stop_testing` event now raise `StopTesting` and unwind to a single
outer handler that exits with the new code - including the parent-side
hung-check path (which used to `break` after killing workers) and the
`create_common_database` failure path (which used to re-raise the original
exception, bypassing the handler entirely).

The job-side parser (`functional_tests_results.py`) treats
`runner_exit_code == STOP_TESTING_EXIT_CODE` as the authoritative
stop_testing signal - no more `STOP_TESTING_SIGN` / `STOP_TESTING_SIGN2`
matching. The constant itself is read straight from `tests/clickhouse-test`
via `runpy.run_path`, so there is a single source of truth.

`ClickHouseProc.run_test` (used by `fast_test.py`) now returns the integer
exit code instead of a bool so this signal reaches the parser for the
fast-test invocation too.

Behavioural change worth noting: when `StopTesting` unwinds from
`do_run_tests` in the parent-side hung-check path, the end-of-main cleanup
steps (final hung check, restarted-tests printing, coverage flush, trace
log analysis) are skipped. This is acceptable since the server is
unresponsive in that path anyway; the diagnostics would fail.

### Changelog category (leave one):
- CI Fix or Improvement (changelog entry is not required)

### Changelog entry:
...
pull Bot pushed a commit to CrazyForks/ClickHouse that referenced this pull request May 29, 2026
…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)
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
Follow-up to PR ClickHouse#105298 (ClickHouse#105298 (comment))
and PR ClickHouse#104081 (ClickHouse#104081).

Previously the job-side parser detected the stop_testing condition (server
died, hung check failed, --max-failures reached, etc.) by matching specific
strings in `test_result.txt`. Every wording change in `clickhouse-test`
risked silently breaking bugfix validation - exactly what happened when
PR ClickHouse#104081 renamed `Server died, terminating all processes...` to
`Stopping tests, terminating all processes...`.

Replace that fragile log-line matching with a stable contract: an exit
code. `clickhouse-test` now exits with `STOP_TESTING_EXIT_CODE = 2` when
the run is aborted via a new `StopTesting` exception (renamed from
`TestRunAbort`, mirroring `StopIteration`). All paths that previously set
the `stop_testing` event now raise `StopTesting` and unwind to a single
outer handler that exits with the new code - including the parent-side
hung-check path (which used to `break` after killing workers) and the
`create_common_database` failure path (which used to re-raise the original
exception, bypassing the handler entirely).

The job-side parser (`functional_tests_results.py`) treats
`runner_exit_code == STOP_TESTING_EXIT_CODE` as the authoritative
stop_testing signal - no more `STOP_TESTING_SIGN` / `STOP_TESTING_SIGN2`
matching. The constant itself is read straight from `tests/clickhouse-test`
via `runpy.run_path`, so there is a single source of truth.

`ClickHouseProc.run_test` (used by `fast_test.py`) now returns the integer
exit code instead of a bool so this signal reaches the parser for the
fast-test invocation too.

Behavioural change worth noting: when `StopTesting` unwinds from
`do_run_tests` in the parent-side hung-check path, the end-of-main cleanup
steps (final hung check, restarted-tests printing, coverage flush, trace
log analysis) are skipped. This is acceptable since the server is
unresponsive in that path anyway; the diagnostics would fail.

### Changelog category (leave one):
- CI Fix or Improvement (changelog entry is not required)

### Changelog entry:
...
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.

6 participants