Repository navigation
Reap the test process groups the abort path orphans - #113393
alexey-milovidov merged 23 commits into
Conversation
A stateless run that aborts can report nothing at all: `files: []`, no server log, no fatal.log, no test rows. The Stateless tests (amd_debug, parallel) run on c41e24c aborted at test 7326/12303 and then emitted nothing for 2 h 17 min until it was killed at the 9000 s ceiling, so the evidence for the server death was destroyed by the abort that was supposed to report it. The parent force-kills its workers on the abort path. A worker killed there is inside kill_process_group's own sleep - the parent's join timeout and that sleep are both 10 s, so this is structural rather than a rare race - and SIGKILL runs no Python finally, so the test process group it was killing survives. Nothing can reap it afterwards, because run_single_test unlinked its PGID record in the finally around proc.wait, which runs before process_result_impl reaches kill_process_group. cleanup_test_groups locates groups only through those records, so both it and `clickhouse-test --cleanup` find nothing. Measured on a local repro: `Process group ... should be killed` is printed 0 times, and the record is removed 26 s before the abort even begins. The orphan keeps the stdout it inherited, which in CI is the write end of `clickhouse-test | ts | tee`, so ts and tee never see EOF and Shell.run's reader threads never join. The plain stateless path passes no timeout, so the wait runs to the job ceiling and the SIGKILL lands inside Shell.run, before the log-collection step. Keep the PGID record until the group is known to be dead, and reap the recorded groups from the parent - the one process still guaranteed alive there, since it masks SIGTERM - before every StopTesting on that path, so the graceful global-time-limit and --max-failures stops are covered too. The reap passes diagnostics=False, which skips both evidence-gathering delays. They are independent and behind different flags: 60 s when SANITIZED (true for every sanitizer job) and 10 s for the client stacktrace. cleanup_test_groups walks records serially, so skipping only one would add a minute per group on exactly the jobs where this failure is most frequent, inside the window the job is being timed against. The default stays True, so the sanitizer report window and the stacktrace dump are preserved everywhere else and no other caller changes behaviour. Verified end to end by killing the server mid-test on a local Debug build: five processes of the test's group survive the runner before this change and none do after, with the runner's exit code unchanged, so the synthetic "Server died" leaf the job side builds is unaffected. The new ci/tests guards fail without the change and pass with it. This fixes no hang and does not explain the server death itself, which is not attributable from a job whose artifacts were never collected. It makes the next occurrence arrive with them attached.
Review round 1 on the previous commit. Six gaps, all in tests/clickhouse-test plus its guard: 1. process_result_impl reached forget_test_process_group only if os.getpgid and kill_process_group both returned. Either raises into TestCase.run's generic handler, which returns UNKNOWN without setting stop_testing, so the worker continues and its next test overwrites the same record path. That leaves a live group with nothing pointing at it, which is the defect this change exists to remove. The kill is now wrapped: the failure is reported, one last SIGKILL is attempted, and the record is dropped in a finally. The per-test alarm path needs no reaper of its own: timeout_handler calls stop_tests, whose cleanup_child_processes already kills the group. That is now stated at the helper rather than left to be re-derived. 2. cleanup_test_groups globbed the repo-wide ci/tmp with no run identity. Safe while its only callers were --cleanup at job teardown; called from a live parent it could SIGKILL a concurrent invocation's in-flight tests, and concurrent invocations over one tree are already a known condition here. It takes an optional worker_pids filter, and do_run_tests records its own worker pids in a set that is never pruned (unlike processes, which is pruned as workers exit, so a worker that died before the abort would be skipped and its orphan missed). 3. The reap sat inside the parallel branch, so no abort out of the sequential runner reached it. Both call sites now go through one bounded, non-raising helper. The sequential runner is the parent, so it passes its own pid too. 4. No test drove do_run_tests, so deleting the reap call left the suite green. The new guard runs the real do_run_tests against a worker stub that records a real group through the real helpers and then has to be SIGKILLed. 5. diagnostics=False documented itself as skipping the evidence gathering but the per-group process listing sat between the two guards, so it still paid an unbounded full ps per record - relocated by this change from a worker the parent can kill into the parent itself, on the one path with no outer timeout. Now gated with the rest. 6. Test hygiene: the shared-directory assumption in the record cleanup is stated, and the killpg swap uses monkeypatch like the rest of the file. Both directions, re-run for this round: all 7 tests fail on the base commit and pass with the change. Four mutation arms, each removing one behaviour from the fixed source, each reddening only the test that owns it. The mutation arm for diagnostics=False was vacuous at first and the probe had to be sharpened: the runner sets SANITIZED and CAPTURE_CLIENT_STACKTRACE False at import, so in the default shape neither arm pays a delay and the flag gates nothing. The guard now sets the sanitizer shape for the run, which is what makes the flag observable. The poll loops no longer call the /proc-wide walk once per iteration, only for verdicts. Note that walking the leader's children file instead is not a valid substitute: when the leader dies first its children are reparented out of that tree, so the walk reports an empty group while live members still hold the inherited fd, which is exactly the state these tests exist to catch.
The previous round removed the PGID record on two paths that do not establish
what the record's own contract requires.
The first is `proc.returncode is not None`. With `start_new_session=True` the
leader's pid is the pgid, and its members can outlive it: `Popen("sleep 30 &
exit 0", ...)` leaves `returncode=0` while `killpg(pgid, 0)` still succeeds and
/proc lists a live member in that group. So any .sh test that backgrounds
something and returns dropped the only pointer to a live group.
The second is a `BaseException` unwinding through the `finally`. The runner's
own `Terminated` is a `KeyboardInterrupt`, so it is not an `Exception` and is
not caught, but the `finally` still runs. The parent's `terminate()` on the
abort path delivers exactly that SIGTERM, and it can land inside
`kill_process_group`'s SIGTSTP wait.
Both leave a group that holds the runner's inherited stdout, which is the wedge
this change exists to prevent, and nothing else recovers them:
`cleanup_child_processes` signals the pgid of each direct child, so a group
whose leader has exited is invisible to it, and the `--cleanup` post-hook is
registered on Fast test only.
Removal is now gated on one `killpg(pgid, 0)`. It is pessimistic on EPERM and
on an unreaped zombie, which is the safe direction: a record that survives one
extra test is consumed by the abort-path reap or by `--cleanup`, whereas a
dropped record is unrecoverable. The leader is reaped with a bounded wait first,
because `proc.wait(args.timeout)` timed out without reaping it and a zombie
satisfies `killpg` indefinitely, which would otherwise leak a record on every
timed-out test.
Two oracles cover the gap that let this through: the stub returned
`returncode=None` unconditionally, so the branch was exercised in neither
direction and a mutation deleting its removal would have reddened nothing.
A record that process_result_impl correctly keeps for a live group was not durable. test_process_group_record() was named for the WORKER, one path for every test that worker runs, and write_text_atomic ends in os.replace, so the retention lasted only until the worker's next run_single_test: the pgid was gone from disk within seconds and the group was unreachable again while still holding the runner's inherited stdout. Measured on the previous head: after a second launch the only record on disk names the second group while the first is still alive. The record is now keyed on the pgid as well as the worker pid. The worker pid stays in the name because it is what scopes a reap to one invocation's own records, so cleanup_test_groups' parse had to stop reading the LAST dot field, which is now the pgid; with the old parse the scoping rejects every record and four of the guards redden. The reap itself ran only inside the stop_testing branch, and the parallel block had no enclosing try. signal_handler raises Terminated from wherever the parent happens to be, so a signal anywhere else in that loop unwound past every reap site to the top-level handler, leaving the group alive with the job's stdout. A worker that simply finishes while holding a retained record had no reap site on its path either. Wrapping the block in try/finally makes the reap unconditional rather than one branch's responsibility. The in-branch call is kept: it must run before the StopTesting raise, while the parent is masked against SIGTERM, and a second pass is a no-op because each record is unlinked in its own finally. Two guards cover this: one drives the real run_single_test and process_result_impl over a leaderless group and then a real second launch, and asserts the first group is alive, its record is on disk, and cleanup_test_groups still kills it; the other signals the parent instead of setting stop_testing and asserts the group is dead. Each reddens only under the mutation that deletes its own behaviour. A legacy two-field record written by an older runner still parses and is still reaped, and --cleanup with no arguments is unchanged. Also fixes two defects in the test helper it extends: the queue it uses leaked a feeder thread, so a later fork warned about deadlocks, and in the signalling shape nothing reaped the workers, which hung the file for an hour.
The reap this PR added to process_result_impl's finally is not observation-only. Popen.wait's _wait calls _handle_exitstatus, which assigns self.returncode, and the same proc object is re-read about 140 lines below to choose the failure reason. So every timed-out test was reported as EXIT_CODE instead of TIMEOUT, and whenever the stderr the classifier reads carried a " <Fatal> " line - ordinary on a sanitizer build, where the client's fatal log is appended to that same file - the reason escalated to SERVER_DIED, which calls stop_tests and raises StopTesting. One timed-out test could therefore abort a whole 12000-test run, which is the damage class this change exists to prevent. Timeout and return code are also distinct buckets in TEST_FAILURE_PATTERNS, so every future timeout would have been mis-triaged in the CI database. Snapshot the decision once, next to the existing pgid local, and classify from the snapshot. Measured on the real function with a real Popen, no wait stub: before, EXIT_CODE with returncode -15, and SERVER_DIED on the fatal arm; after, TIMEOUT on both arms, matching the merge-base, with the group still fully dead. The wait itself is kept: removal is gated on killpg(pgid, 0), an unreaped zombie leader still answers that probe, and without the reap two existing tests fail because the record outlives the group on the normal timeout path. Add the oracles that pin the reason. The one existing arm that asserted TIMEOUT drove a SimpleNamespace whose wait was a plain attribute, which cannot mutate returncode, so it was blind to this by construction. The new tests hand a real Popen straight to process_result_impl and assert the precondition that the leader is still unreaped. Scope the reap to the invocation rather than to a pid. worker_pids holds bare numbers and is deliberately never pruned, the records live in the repo-wide ci/tmp that concurrent invocations over one tree share, and pid_max is finite, so a retired worker's pid recycled into a concurrent run's worker would have put that run's live tests in this run's sweep. Records now carry a token minted once per invocation; workers are forked, so they inherit it (measured). The --cleanup path keeps matching every record shape, including ones written before this change, because it is an orphan sweep that runs when nothing else is live. Mask SIGTERM across the two new outer reaps, as the abort block above already does. The reap catches Exception, and the runner's own Terminated is a KeyboardInterrupt, so a signal landing in the finally would have replaced an in-flight StopTesting and the job side would have read 143 instead of the exit code it parses. Widening the catch to BaseException was rejected: it would swallow a genuine Terminated. Also fix the two documentation snippets, which called both helpers with no pgid and would have raised TypeError if copied.
The sentence added for the --cleanup shape-agnostic note used an em-dash, which is not allowed in ClickHouse contributions.
The token that scopes the abort-path reap to one invocation was minted in the module body, which makes it invocation-wide only under fork. __main__ selects the spawn start method whenever CHECK_NAME contains aarch, and a spawned worker re-executes the runner as __mp_main__ and minted its own token. Every record it wrote therefore failed cleanup_test_groups' token comparison, and the parent-side reap walked past all of them: an orphaned test group survived the abort and kept holding the job's stdout, which is the wedge this whole change exists to close. Measured on a real spawned worker before the fix, the group survived the reap (alive=[3652939, 3652940, 3652941]) while the fork arm was reaped correctly, and the sequential shape, whose record the parent writes itself, was also correct - so the defect was specific to a worker-written record under spawn. Live carrier: Bugfix validation (functional tests, aarch64), which runs clickhouse-test --jobs <nproc> down the parallel path. Seed the token through the environment instead, which both start methods propagate. A nested invocation must not adopt an outer run's token, or its sweep would match the outer run's in-flight records, so a top-level invocation re-mints. The guard keys on __name__ rather than on the pid prefix alone: a spawned worker also sees a foreign prefix, because the token it inherited was minted by its parent, and it must keep what it inherited. Only __main__ distinguishes the two, since a spawn child re-executes the module as __mp_main__. cleanup_test_groups' matching rule is unchanged. The defect was the token's lifetime, not the comparison, and loosening the comparison to a pid-only match would reintroduce the recycled-pid hazard that test_a_recycled_worker_pid_does_not_widen_the_reap forbids. The --cleanup orphan sweep stays shape-agnostic and still consumes a foreign-token record. Two arms cover this. The existing scoping arms build their foreign record from a hand-written string, which pins the matching rule while never asserting that a real worker's record can satisfy it, which is why 17 of 17 passed against a contract that was void on aarch. The new spawn arm has a real spawn child write the record through the real helpers, obtaining its token the way a worker does rather than being handed it, and judges group liveness. The nested arm drives a real subprocess with the variable pre-set. Verified by mutation: reverting the token to a per-process mint reddens the spawn arm, dropping the re-mint reddens the nested arm, and loosening the comparison reddens the recycled-pid arm. Running the new arm under fork, or handing the token to the child, leaves it green on unfixed code, which is what makes the chosen shape load-bearing.
The reap catches `except Exception`, and the runner's own `Terminated` is a `KeyboardInterrupt`, so a signal arriving inside it is not caught: raised from a `finally` it replaces the exception unwinding through it, and the job side then reads 128+signal / "terminated unexpectedly" instead of the exit code it parses. `__main__` routes SIGTERM, SIGINT and SIGHUP to that handler, but the reap was guarded against SIGTERM alone - the two masks added with the new call sites mirrored the pre-existing abort-block one, which is itself SIGTERM-only. So the "reap on every exit" invariant held for one of the three signals. praktika only ever sends SIGTERM then SIGKILL, and the runner has no controlling terminal (`start_new_session=True`), so CI is not affected today; a developer pressing Ctrl+C during the reap is, and loses the test group holding their terminal. Mask inside `reap_recorded_test_groups` instead of at the call sites, so a site added later cannot miss the guard, and drop the two masks this branch added. The pre-existing mask at the abort block stays: it spans the whole terminate / join / kill sequence, not just the reap, because a worker's `stop_tests()` broadcasts SIGTERM to the group and would otherwise reach the parent mid-join. Nesting is harmless - the function restores whatever disposition it found. The existing arm asserting a real signal delivered from inside the reap gains a second parametrisation axis over the three signals. Removing any one of them from the mask reddens exactly that signal's two arms.
Internal second-model review (7 rounds, final round clean)Before opening this, the change went through an internal review pipeline: an Round 7 (final) - cleanThe second-model pass returned no findings. My own cold pass found no blocker
Round 6 - the reap was guarded against
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20260804-185300 |
|
cc @leshikus @maxknv, could you review this? On the abort path the parent force-kills a worker that is inside |
|
Workflow [PR], commit [c4eea1c] Summary: ✅ AI ReviewSummaryThis PR hardens Final Verdict✅ No new blockers or major issues found in the current revision. LLVM Coverage ReportMeasured on commit c4eea1c.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +158 lines in 47 files (-124 lines lost coverage) · Details |
The reap walks the record directory once, so it is only complete when no
worker can still add a record. The `finally` added for the abort path ran
that walk while every worker was still live, so a sibling could write its
next `<token>.<worker>.<pgid>` after the walk had passed the directory.
Nothing walks again, so that group survived holding the runner's stdout,
which is the failure this whole path exists to prevent.
Measured on the unfixed runner, instrumenting the worker's write and the
parent's glob separately: the walk saw one record while two worker pids
were in scope, and the second group was still alive afterwards with its
record still on disk. It is the record's absence at walk time, not the
scope, that leaks the group.
The `stop_testing` branch already had the right sequence and documented
the reason ("Safe only here: every worker is joined, and the parent is
the last process still alive"). That sequence is now a helper used by
both sites, so the precondition holds wherever the reap runs. The scope
stays `worker_pids` - this does not widen the sweep.
`processes` is bound before the `try`, because an exception between the
`try` and the worker loop (`multiprocessing.Value`, `Manager`, or a
signal) otherwise made the teardown raise `UnboundLocalError` and replace
the real cause.
Reported by the AI reviewer on the PR, which named the mechanism and the
reproduction. Its trigger (a signal to the parent alone) is developer
local rather than a CI shape: praktika signals the whole process group
(`os.killpg`, ci/praktika/utils.py:291 and :309) and the one
pid-targeted helper has no callers. The same `finally` is reachable in
CI with no signal at all, through an exception out of the poll loop's
liveness, memory or lldb helpers.
The new guard asserts the liveness invariant rather than a surviving
group, so it is deterministic in both directions; whether a given
interleaving actually loses a record is a race. Mutation-checked: the
outer quiesce, the reap itself and the `processes` hoist each redden a
distinct arm and nothing else.
|
Confirmed and fixed in e27f594. I reproduced your case 3/3 with the fixture unchanged, then instrumented the worker's The second worker's pid was in scope, so the sweep was scoped correctly; the record simply The One correction to the framing, since it affects how the risk reads. A signal reaching the On the new coverage: I did not add your I also disagree with one point I want to record rather than leave implicit, since a later
|
|
Updated pre-PR validation gate for e27f594. The arm counts in rows (a) and (d) changed with the two new oracles (twenty functions collecting twenty-five arms, re-derived from the AST and confirmed by collection); rows (e), (f) and (i) record the new mutants and the single-pass-walk invariant. Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20260804-185300 |
Master landed the stop-cause carrier (try_claim_stop_cause / raise_stop_from_carrier) across the same lines this branch re-indented when it wrapped the worker pool in a try/finally. One conflicted file, three hunks, all in do_run_tests, and no competing fix: the carrier decides which exit code the run reports, the reap decides which process groups are killed first. Resolution takes master's text at this branch's indentation, and drops this branch's local global_time_limit_reached flag plus its stop_exit_code.value ladder. Both were a single-process re-implementation of "remember why the run stopped"; the carrier does it across processes, which the local flag could not, since a worker's StopTesting never reaches the parent. GLOBAL_TIME_LIMIT and MAX_FAILURES still surface, now through the worker-side claims and raise_stop_from_carrier. Master's claim-based guard also replaces the racy `not stop_testing.is_set()` pre-check that the local flag needed. The merged abort sequence was verified rather than assumed: claim, collect stacktraces, stop the workers and reap their recorded groups, then classify. The reap cannot remove a process the trace collection needs, because print_c_stacktraces resolves server pids via get_all_server_pids, which is deliberately not pgid-scoped, while the reap only kills pgids read from clickhouse_test_group_pid records, that is test groups. Master also deleted ci/tests/test_cleanup_test_groups.py, untouched by this branch; the deletion is accepted as master's. Both test files still fail when they should: 25/25 and 14/14 green on the merged tree, and one mutant per guard site reddens a distinct arm (dropping the outer reap fails 2, restoring the unconditional record drop fails 1, binding `processes` late fails 1). The three ruff findings on tests/clickhouse-test are present identically on pristine master.
Three comments still described the pre-token record format: that a worker's next test overwrites the same record path because it is named for the worker's pid, and that records carry no run identity. Records are named clickhouse_test_group_pid.<token>.<worker>.<pgid>, so each group has its own record and the token IS the run identity the scoping test asserts. Comments and one assertion message only.
|
Merged master to clear the conflict ( Master had landed the stop-cause carrier ( Ordering, since reaping and stacktrace collection now meet on the same path: verified as Master also deleted Both test files still fail when they should, which is the part a rebase can silently break: One follow-up in the same push: three test comments still described the pre-token record The branch now carries 11 commits, so it wants a squash before the next review pass. I left |
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 units416 translation units recompiled, 3547 s compile time in total, 416 of them have a recent master baseline. |
…uite Two independent failures of this PR's own `CI Tests` job, both in test fixtures. `process_result_impl` now reads the pgid on every arm, not only on the timeout one: the record cleanup added here drops a record once the group is gone, which is a decision the normal-exit path has to make too. `_FailedProc` stands in for the declared `Optional[Popen]` and carried only a `returncode`, so four pre-existing classification tests raised AttributeError. Completing the stub keeps the runner's contract as it is; narrowing the read back was measured not to help, because those four take the normal-exit branch that needs the pgid. Its pid is our own, so the group is alive and the cleanup is a no-op there. The nested-invocation arm drove `clickhouse-test` with a bare argv on the assumption that it exits early for want of a binary or a server. This job supplies both, so it started a whole test run instead and was killed at the subprocess timeout. `--help` returns from `parse_args`, which is still after the module body that mints the run token, so the arm asserts what it asserted before: with the re-mint guard disabled it fails either way, with or without a binary on PATH.
|
Four pre-existing arms in One arm of mine hitting its subprocess timeout. Verification, on this worktree with only One residual I am not fixing here, disclosed rather than left to be found: a record retained |
…e sweep The conflict offered master's copy of the parent monitor loop against this branch's post-loop comment, but the merge had already placed this branch's restructured loop above it - wrapped in `try`/`finally` and reaping through `quiesce_workers_and_reap` instead of the inline terminate/join/kill. Dropped that duplicate body and kept this branch's structure. The one master-side change inside the region is the SQL stacktrace sweep added to the hung-check path in ClickHouse#113059, which this branch predates; re-applied it before `print_c_stacktraces`. Verified by running `ci/tests/test_abort_path_reaps_test_groups.py` and `ci/tests/test_hung_check_exit_code.py` before and after the merge: no test fails after it that did not already fail on this branch's head, and `test_new_reason_is_matched_by_a_failure_pattern` now passes. The rest are this environment's Python 3.14 `multiprocessing` forkserver failures. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Master removed the whole `ci/tests` directory in `5b3d66b1a66` ("Remove ci/tests
(attempt 2)", 51 files, no replacement location), so this branch's edits under
`ci/tests` arrive as modify/delete conflicts. Accepted the removal, and dropped
the files this branch adds there as well - keeping them would re-create a
directory master deliberately deleted.
The product change this pull request is about is unaffected; what is lost is its
CI-side unit coverage, which has nowhere to live upstream any more.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ned-test-groups-on-abort Resolve the conflict in `tests/clickhouse-test`: master extracted the worker stop into `terminate_workers`, which `quiesce_workers_and_reap` now calls instead of its inline copy of the old flat-10s version. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
@groeneai, fix conflicts. |
…ned-test-groups-on-abort Resolve the conflict with ClickHouse#119793 in `do_run_tests`: keep its worker pool (`live_workers`, `start_worker`, `reap_finished_workers`, the recovery threshold) inside the `try` whose `finally` reaps, and register each pid in `worker_pids` inside `start_worker`, so a worker started again after a shed is covered by the abort-path reap like the initial ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ned-test-groups-on-abort Keep ClickHouse#112265's new stdio invariant section in the process management document ahead of the renamed PGID-tracking section; the rest merged cleanly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since ClickHouse#112265 the per-test wrapper gets its own stdout and stderr, so a group that outlives the run no longer holds the pipeline the runner heads. Two comments still gave that as the reason the group must be reaped; say only that it stays live, which is still true. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged master in 988105f and c6ee85e; the conflicts were with #119793 and #112265. |
… test The `ci/tests` guards for the abort-path reap went away with that suite (ClickHouse#115650), leaving no automated coverage. `tests/integration` is the remaining collected pytest root, so the essential oracles move to a cluster-less module there, `test_clickhouse_test_abort_reap`, which loads `tests/clickhouse-test` as a module and drives real process groups: - `reap_recorded_test_groups` reaps only records of this run's `_CLICKHOUSE_TEST_RUN_TOKEN` and of the named workers; - a `spawn` worker inherits the token, so its records are in the reap scope; - SIGTERM/SIGINT/SIGHUP during `reap_recorded_test_groups` and during the worker stop in `quiesce_workers_and_reap` do not raise `Terminated`; - `quiesce_workers_and_reap` stops a worker that keeps recording groups before the single walk, so no record or group survives. Each test was checked to fail against a runner with its contract broken (token check dropped, token not seeded through the environment, signals not masked, reap before terminate). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ned-test-groups-on-abort Conflict with ClickHouse#122522 in `process_result_impl`: master passes `proc.pid` to `kill_process_group` instead of `os.getpgid(proc.pid)`, which fails with ESRCH on macOS for an exited, unreaped leader. Kept this branch's timeout path and record bookkeeping, calling `kill_process_group(pgid, ...)` with the `pgid = proc.pid` it already binds; same in the process management notes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`clickhouse-test --cleanup` calls `cleanup_test_groups` without `worker_pids`, so it must not parse record names: on a reused runner `ci/tmp` can hold a record of a killed invocation (another token) and one an older runner wrote as `clickhouse_test_group_pid.<worker>`. Nothing covered this after `ci/tests` was removed. The new arm writes both, calls `cleanup_test_groups` and checks that both groups are killed and both records removed. It fails if the sweep starts parsing names (the legacy record is skipped) or filtering on the token (the killed invocation's record is skipped), while the other tests of the module stay green in both cases. Also drop the module docstring's claim that a regression here brings back the hung `clickhouse-test | ts | tee` pipeline: since ClickHouse#112265 a test group no longer holds the runner's stdout or stderr. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #112911
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
When a stateless run aborts, the report can come back empty:
files: [], no server log, nofatal.log, no test rows. ThisStateless tests (amd_debug, parallel)runaborted at test 7326/12303 and emitted nothing until the 9000 s job timeout.
Root cause: the parent force-kills its workers on the abort path. A worker killed there sits
inside
kill_process_group's ownsleep, and SIGKILL runs nofinally, so the test processgroup survives, holding the inherited stdout, and
clickhouse-test | ts | teenever sees EOF.Nothing can reap it either:
run_single_testunlinks its PGID record in thefinallyaroundproc.wait, beforeprocess_result_implreacheskill_process_group. #112265 has sincestopped it from wedging the pipeline; it still outlives the run.
The change keeps the record until the group is gone, checked with
killpg(pgid, 0)ratherthan inferred from the leader's exit status, and names it
<run token>.<worker>.<pgid>, so akept record survives that worker's next test and a reap is scoped to one invocation: the
records are repo-wide and a live parent must not signal another invocation's tests. The token
is seeded through a new
_CLICKHOUSE_TEST_RUN_TOKENvariable, because aspawnworker(selected for
aarchchecks) re-executes the runner and would otherwise mint its own. Reapingruns in the parent, the only process guaranteed alive there, in a
finallyaround each runner,so a signal to the parent and a normal finish are covered too. It passes
diagnostics=Falsetoskip what is otherwise paid per group, serially: a 60 s sanitizer wait, a 10 s stacktrace wait,
an unbounded
ps.Verified by killing the server mid-test on a local Debug build: five processes of the group
survive on
master, none with this change, exit code unchanged. The originalci/testsguardswent with that suite (#115650); the abort-path contracts (token and worker scoping,
spawnpropagation, signal masking, quiesce before the reap) are now pinned by the cluster-less
integration test
tests/integration/test_clickhouse_test_abort_reap. This does not explain the server death.Workflow [PR]
Sync PR [sync-upstream/pr/113393]
Version info
26.10.1.1130-master(included in26.10and later)