Repository navigation
CI: collect server stacktraces on server death, simplify stop logic - #104081
Conversation
…tion Call `print_stacktraces` at the two points where server death is first detected: when a test result comes back with `FailureReason.SERVER_DIED`, and when the liveness hung-check finds the server unresponsive. Replace all `raise ServerDied` with `break` — the `server_died` event already signals all workers to stop, and `main` already sets exit code 1 when the event is set, so the exception was redundant. Remove the `ServerDied` class and its top-level handler entirely. The two non-server-death stops (`--max-failures` limit and max failures chain) now print an explicit message before breaking instead of relying on the exception message.
…_chain Without this, breaking out of run_tests_array for these two cases left server_died unset, so main's suite loop would continue running subsequent test suites instead of stopping.
The flag is set not only when the server dies but also when --max-failures or the failures chain limit is reached. `stop_testing` better describes its role as a general "stop all test execution" signal.
|
Workflow [PR], commit [326fd24] Summary: ✅ AI ReviewSummaryThis PR updates Missing context
ClickHouse Rules
Final VerdictStatus: ✅ Approve |
|
IMHO, it's more error-prone to replace exception with break. We can break just the nested loop. Also, we still have GlobalTimeout exception and bare raises. The approach now is mixed. I'd prefer a separate exception for each reason, with distinct exit codes. |
|
@maxknv the problem with the exception is a broken metaphor; we generally should be able to throw it everywhere; this is not the case for multi-process code, we have to stop other processes before throwing the exception; please let me know if I should restore exception |
Bring back the `ServerDied` exception class, the four `raise ServerDied` call sites in `run_tests_array`, and the top-level `except ServerDied` handler, reverting the control-flow part of the earlier refactor. The `stop_testing` rename and the `print_stacktraces` calls at the two server-death detection points (test result with `SERVER_DIED` reason and hung-check liveness failure) are kept. The `stop_testing.set` calls at the `--max-failures` and `max_failures_chain` sites are also kept so the main suite loop still observes the stop signal across processes.
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
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: ...
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: ...
clickhouse-testhas aprint_stacktracesfunction that collects gdb/system.stack_tracebacktraces, but it was only called at startup and during the hung-query check — never when the server was detected dead mid-run. This left the most important failure mode without any trace output.Changes
Stacktrace collection on server death —
print_stacktracesis now called at the two earliest detection points:FailureReason.SERVER_DIED(inrun_tests_array)do_run_tests)Removed
ServerDiedexception — the exception was raised immediately after setting theserver_diedevent, so it was redundant: the event already signals all workers to stop, andmainalready sets exit code 1 when the event is set. Replaced all raises withbreak. The two non-server-death stops (--max-failureslimit and max failures chain) now print an explicit message before breaking. A bug was also fixed where these two cases did not set the stop flag, somain's suite loop would continue into subsequent suites.Renamed
server_died→stop_testing— the flag is now set for--max-failuresand failures-chain limits too, not only for actual server death, so the old name was misleading.Changelog category (leave one):
Version info
26.5.1.456