Repository navigation
Do not report "Server died" when only the liveness check failed - #115080
Conversation
A hung-check verdict and an observed server death were the same exit code, so the job side reported both as "Server died". Measured on the flaky-check run that prompted this: the aggregate said "Failed: 0, Passed: 3872", the server log showed a clean shutdown with no <Fatal> line and no sanitizer report, and the harness had located a live server process and attached lldb to it moments before the verdict was formed. tests/clickhouse-test collapsed every in-band abort cause into STOP_TESTING_EXIT_CODE, and ABORTED_RUN_EXIT_CODES appends the synthetic "Server died" leaf for that code unconditionally. Two other causes had already been carved out of it for the same reason (GLOBAL_TIME_LIMIT_EXIT_CODE, MAX_FAILURES_EXIT_CODE), each with a dedicated leaf; the hung check is the third. Adds HUNG_CHECK_EXIT_CODE and FailureReason.LIVENESS_CHECK_FAILED, reported as "Server liveness check failed" at FAIL. The four sites that concluded SERVER_DIED from a failed check_server_liveness probe now use the new reason; the site that concludes it from a <Fatal> line in stderr is unchanged, and the one next to it becomes an elif of it, since as two independent ifs a stderr carrying both signals hit both and the second won, downgrading real fatal evidence. The name states the observation rather than a diagnosis. check_server_liveness catches a bare Exception and clickhouse_execute_http raises on any non-200, so a server that does respond, with 503 CANNOT_SCHEDULE_TASK for instance, fails the check; "unresponsive" would overclaim in the same way "died" does. The stop cause now travels through one locked first-writer-wins helper that all writers share, and the parent claims the global time limit through it as well. That replaces global_time_limit_reached, which was a second copy of the same state: its check-then-set discarded a cause a worker claimed during the window, and the window is real because the claiming worker then collects stacktraces, which blocks up to 30 seconds per server process. Hence the ordering at every detecting site: claim, collect, then set the event. The event goes last because once it is set the parent waits only five seconds before terminating workers. A parallel worker on the new path does not call stop_tests(). Its killpg broadcasts SIGTERM to the whole group including the parent, which would exit 143 before consuming the claimed code, and 143 is itself reported as "Server died" - so the fix would silently undo itself. The sequential runner owns the main process and still calls it. This mirrors the --max-failures branch, whose comment documents the same hazard. The randomized-settings diagnostics artifact is not saved for the new reason. The artifact asserts that a test fails under those settings, which a server-wide stall does not establish, and --diagnose-random-settings replays it. Consumers of the strings, enumerated by grep rather than by reasoning: TEST_FAILURE_PATTERNS gains the new reason value, because process_result writes reason.value into the per-test output and cidb.py matches those strings to build the cause-filtered history link, so a value matching nothing loses that link for every witness; SYNTHETIC_TEST_NAMES gains the new leaf, since a run-wide abort names no single change to revert. check_ci.py's "Server died" reference is Stress-only and Stress has its own parser, so it is untouched. "Server liveness check failed" is a new test_name in CIDB, so historical "Server died" queries will not match it. That separation is the point. The aggregate status and is_failure() are unchanged, so no job becomes benign, including bugfix validation, where a hang counts as a reproduction exactly as a death does, and Fast test, which also passes --hung-check. Tests: 7 parser cases and 20 runner cases, the latter covering the carrier for every ordered pair of causes, each of the four decision sites, the string and artifact consumers, and the exit code the process actually returns. That last layer is the only one that can observe the killpg corruption, which surfaces as 143 rather than as a wrong reason.
The carrier only helps where it is read. The parent monitor loop checks stop_testing at the top of an iteration but reaps workers at the bottom, and the reap is the loop's own exit condition, so a cause claimed in between was never consumed. With sequential tests in the suite control then fell to the sequential runner, whose stop arm raised StopTesting with no exit_code and so returned the default 2 - which the job side reports as "Server died", the exact defect this branch fixes. Without sequential tests the loop exited normally and the dead worker's non-zero exitcode set exit code 1, which is deliberately not in ABORTED_RUN_EXIT_CODES, so neither leaf was emitted. Both consumers now read the carrier through one helper, falling back to the default when nothing was claimed - 0 means unset and must never become an exit code. Tests for the three sites that were untested. The ConnectionError arm was reachable by no test, so any one of the three probe-only conclusions could be reverted with everything still green. The claim on the death path, and its position before the stacktrace sweep, likewise had no test; asserting the raised code cannot see it, because the sequential arm raises the default and the default equals the death code, so the assertion is on the carrier. Both orderings are driven with a real blocking collection window and the causes swapped, so neither passes on an implementation that never claims. test_carrier_uses_the_value_lock pinned lock entry rather than lock scope: an empty critical section with the read-modify-write outside it passed all three of its assertions. The carrier is now a property whose getter and setter assert the lock is held, and a test drives that defect to prove the probe rejects it. Seven mutation arms, each reddening one named case: dropping exit_code= from the sequential arm, dropping the unset-carrier fallback, deleting the post-loop consumer, deleting or moving the death-path claim, moving the liveness claim, and taking the read-modify-write outside the lock.
The test that pins "an abort site claims its cause before it spends 30s per process collecting stacktraces" scheduled its interleaving with two independent sleeps: the competitor thread slept 1s, the stubbed collection slept 4s, and the only post-run assertion was that the collection had run. Under the current code that is deterministic. In the direction that gives the test its value it is not. On a tree where the claim sits below the collection, a competitor thread that is not scheduled inside those 4s lets the production code claim first, the competitor loses, and the arm passes on the defect. sleep releases the GIL, so that is improbable rather than impossible. The window is now a two-way event handshake with no sleeps in the ordering path. The collection opens the window, the competitor waits for it, claims, and signals back; the collection waits for that signal instead of sleeping, so the window is exactly as long as it needs to be and provably contains the competitor's attempt. Both events are asserted afterwards - the second one was what was missing. Every wait is bounded and a missed handshake raises with the name of the handshake that was missed, so a starved thread fails loudly instead of hanging a CI job. One new case drives the harness's own failure mode: with no competitor started, the driver must raise rather than pass or hang. Without it the new waits could be satisfied vacuously. Both ways of defeating the guard were measured to redden it, and the three mutations the invariant exists to catch (deleting the death-path claim, moving it below the collection, moving the liveness claim below its own) now redden their cases deterministically, three runs out of three. Also widen the STOP_TESTING_EXIT_CODE docblock, which claimed the code means a server death was observed. Two live raisers of it involve no death: the common-database setup failure, and a stop whose cause was never claimed.
Three test-only gaps found by review, all the same shape: an arm whose interleaving or classification was raced rather than forced. The sequential side of the is_concurrent split was executed by no test. _make_suite writes untagged fixtures and is_sequential_test only matches an --sequential substring or a no-parallel tag, so -j 1 still produced parallel workers and the "sequential" arm was a second copy of the parallel one; stop_tests() could be made unconditional with everything green. The arm now passes --sequential=sleep and asserts the split the runner prints, with a negative control requiring the parallel configuration not to satisfy that assertion. A second arm records stop_tests() calls and pins 1 when sequential and 0 when concurrent, which the exit code cannot see because both sides exit 5; it asserts the carrier too, so a count of zero cannot come from never reaching the site. The in-loop consumer arm keyed on the teardown banner, which is printed before the raise it was meant to pin, so it passed with that raise deleted. It now records which call site raised, with the two line numbers derived from the runner source so a refactor fails loudly instead of comparing against a stale line. Its ordering is forced by an event that waits for a worker to signal, the inverse of the existing hidden-once event, and an unmet handshake raises rather than hanging. The two arms asserting an ordering against --global_time_limit measured a budget that also covered database creation and worker startup, so a slow runner made correct code claim the time limit and exit 3. The test shim re-arms the deadline on entry to the monitor loop and the arms assert that it did, so the budget covers the window under test.
…uard The two arms that pinned "a cause claimed first is not displaced by the global time limit" reached the deadline end to end, which put process startup - the multiprocessing manager fork and one fork per worker - inside the budget they had to outrun. Measured at ~20 ms against a 3-4 s budget, so the margin was large, but it is not bounded on a shared runner: a slow enough runner makes correct code claim the time limit first and both arms fail. One of the two was worse than unbounded - it never reached the deadline at all. Instrumenting try_claim_stop_cause showed zero time-limit claim attempts across three runs, because the monitor loop raises in the same iteration the parent's probe sets stop_testing, so the deadline is not re-evaluated. It could not observe the ordering it was named for. Drive the ordering in-process instead, with the deadline and the clock reading both constants and a handshake putting the worker's claim first on every run. The retained end-to-end arm keeps its generous budget because it now carries only the exit code, which is the one layer that can see killpg clobbering it; it also asserts that the time limit tried and was refused, since that claim's banner is printed inside the granted branch and a run where the deadline never expires exits 5 without the two causes ever competing. The probe's new `not stop_testing.is_set()` guard had no arm: deleting it left every test green. The exit code cannot see it - under the CAS a second claim loses either way - so count the calls instead, with the positive control the count needs to mean anything, and a second control for the --hung-check half of the condition. Also replace the em-dash on the one added line in print_c_stacktraces's docstring with a plain hyphen.
The end-to-end arm for "an expired time limit does not steal a cause the worker already recorded" had to make the run outlast a deadline to reach the interleaving, which put the manager and worker forks inside the same budget. Fork latency on a shared runner is unbounded, so the parent could legitimately claim the time limit first and the arm would fail on correct code. Both halves of what it asserted are already pinned by arms that own their clock: the ordering by the in-process handshake, the exit code by six other end-to-end arms. Removing it also retires the deadline re-arm shim and the blocking-collection knob, whose only caller it was. Moving the liveness claim below the stacktrace sweep still reddens three cases, so the production defect stays covered. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 6 review rounds, 12 findings,
Severity: ❌ blocker / One thing I noticed and am not raising separately, since it has no user-reachable consequence: Session id: cron:clickhouse-review-slot-10:20260817-051100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-10:20260817-051100 |
|
Workflow [PR], commit [bfd4885] Summary: ✅ AI ReviewSummaryThis PR separates mid-run liveness-probe aborts from the generic Final Verdict✅ No blocking issues found. |
|
cc @maxknv @PedroTadim, could you review this? |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units7 translation units recompiled, 4 s compile time in total, 7 of them have a recent master baseline. |
The synthetic leaf was renamed to name the observation rather than a diagnosis, because check_server_liveness also returns False on a non-200 response. Three user-visible messages on the same path still said the server was not responding or unreachable, so a 503 kept reading as a server that had stopped answering. Prose only. The FailureReason value, the exit code and the leaf name are unchanged, so no CIDB signature and no TEST_FAILURE_PATTERNS token moves. Co-Authored-By: Claude Fable 5 <[email protected]>
The reap at the bottom of the monitor loop is the loop's exit condition, so hiding one observation of the event only lands the claim in the check-to-reap gap when the worker is already dead. A worker that lingers half a second after setting the event makes correct code take the in-loop consumer instead, and the two post-loop arms fail on it. Measured: with the worker lingering 0.5s the arms recorded the in-loop consumer line; with the join in place they record the post-loop one. An unjoinable worker now raises naming the timeout rather than passing quietly. Co-Authored-By: Claude Fable 5 <[email protected]>
The worker abort sites had an arm driving a competitor inside the stacktrace sweep; the parent's probe site did not, so moving its claim below the sweep left all 703 tests green. The parent's carrier is created inside do_run_tests, so the arm captures it from the first claim and hands that same object to the competitor. Measured: with the claim below the sweep the arm fails naming the defect in 0.24s; with it above, the arm passes and the sweep's own handshake proves the competitor ran inside the window. Also drop the death-discrimination claim from check_server_liveness's docstring. A non-200 response raises, so False does not establish that the server is gone, which is the same reason the leaf names the observation. Co-Authored-By: Claude Fable 5 <[email protected]>
The existing arms pin the helper's own semantics, but each decision site starts from an empty carrier and writes before anything competes, so replacing any of the five calls with a plain stop_exit_code.value assignment produced the same values and left all 704 tests green. Measured: bypassing all four worker sites, or just the parent's probe site, now fails naming the offending line. The write's spelling is checked over the whole file by AST rather than a listed set of lines, with the helper's own write excluded and a claim-count control so zero direct assignments cannot pass on a file that stopped claiming altogether. Co-Authored-By: Claude Fable 5 <[email protected]>
The parent-probe arm started a competitor thread before do_run_tests forked its workers, and CPython warns that forking a process which has started a thread may deadlock in the child. The competing claim does not need a thread: the stubbed sweep already runs inside the window it has to land in, so it claims there. Deterministic rather than raced, and the arm still fails in 0.24s when the claim moves below the sweep. The suite's warning count drops by the one this arm added. Co-Authored-By: Claude Fable 5 <[email protected]>
CI finish ledger — bfd4885CI finished with no live failures: 179 check runs, 0 incomplete, 0 failed, The result database does hold 4 failure rows for Session id: cron:our-pr-ci-monitor:20260818-000000 |
|
Ok. |
783f26c
Master's ClickHouse#115080 added HUNG_CHECK_EXIT_CODE to ABORTED_RUN_EXIT_CODES and a per-code leaf selection, which conflicted textually with this branch splitting the kill-by-signal codes into their own set. Resolution keeps both: KILLED_BY_SIGNAL_EXIT_CODES holds only the four signal encodings, and ABORTED_RUN_EXIT_CODES is derived from it plus both in-band codes, so exit 2 and exit 5 keep their own branches and leaves. The two test suites were disjoint additions on a shared prefix and are both retained. Verified after the merge: the four signal encodings take the new branch, while exit codes 2, 4, 5 and 3 each still take their own master path (no dead branch, no double handling), and the 23 remaining ci/tests/ failures are byte-identical to a pristine master tree (no clickhouse binary in PATH).
master split FailureReason.SERVER_DIED into SERVER_DIED and LIVENESS_CHECK_FAILED (ClickHouse#115080), and re-routed three of the four former SERVER_DIED sites to the new reason. The condition this branch covered through the SERVER_DIED abort site now arrives as LIVENESS_CHECK_FAILED, so the SQL dump is added at that site too; a textual union merge would have left the new path collecting C stacks only, silently dropping the query_id mapping this branch exists to provide. Both abort sites claim the stop cause before collecting, per master's ordering invariant: collection can block ~30s per server process, and a cause claimed afterwards loses to any cause claimed during it. Kept this branch's removal of the liveness pre-check in print_sql_stacktraces. The pre-check probes HTTP while the dump runs over native TCP, so a failed probe does not predict whether the dump can run, and get_stacktraces_from_clickhouse is bounded and never raises. Adopted master's "liveness check failed" wording, which names the observation rather than diagnosing a death.
Do not report "Server died" when only the liveness check failed
Related: #110479
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Stateless tests (amd_tsan, flaky check)on #110479 @038667a9c024reported a singlefailing leaf
Server diedwhile its own aggregate saidFailed: 0, Passed: 3872. The serverdid not die: no
<Fatal>line, no sanitizer report, emptydmesg, clean shutdown. The--hung-checkliveness probe failed and the run was aborted.Report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110479&sha=038667a9c024695126415fe5f37b76f7a06662fa&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20flaky%20check%29
Root cause:
tests/clickhouse-testcollapses every in-band abort cause intoSTOP_TESTING_EXIT_CODE = 2, and the job side appendsServer diedfor that codeunconditionally. Master already carved two causes out of code 2 for this reason; this is
the third.
This adds
HUNG_CHECK_EXIT_CODE = 5andFailureReason.LIVENESS_CHECK_FAILED, with the leafServer liveness check failedat status FAIL. All four sites that concludeSERVER_DIEDfroma failed probe are changed; the site concluding it from a
<Fatal>line is untouched, and itsneighbour becomes an
elifof it so fatal evidence is never downgraded. The stop cause travelsthrough one locked first-writer-wins carrier, replacing a
global_time_limit_reachedflag.The leaf names the observation, not a diagnosis:
check_server_livenessalso fails on anon-200 response. It is a NEW CIDB
test_name. The aggregate stays FAIL, so bugfixvalidation still counts a hang as a repro.
Not claimed: a remaining
Server diedrow still does not prove a death. Code 2 is generic, anda worker seeing a
<Fatal>line reaches the parent throughstop_tests(), exiting 143 -correct there, but decided outside the carrier.
Validation: +50 tests asserting the process exit code end to end - the same command exits 2 on
master and 5 here. Each changed site has a mutation arm reddening a named case.
ci/tests: 705passed, 655 on master.
Successor to #112952, not an extension: that PR deliberately excludes exit code 2. Both touch
the same region of
functional_tests_results.py, so the second to merge needs a rebase.Version info
26.8.1.1807(included in26.8and later)