Repository navigation
Conversation
Stateless jobs intermittently finished with a job-level ERROR after producing no output at all for almost two hours, until the 9000s job watchdog killed them. No test failed and no server log was ever uploaded, which is what made this class unattributable: the job was SIGKILLed before CHECK_ERRORS and COLLECT_LOGS, so the crash trace, the sanitizer report and the dmesg OOM check were never produced. Their absence said nothing about the server. ci/jobs/functional_tests.py runs the suite as a shell pipeline, `clickhouse-test ... | ts | tee -a`, and run_single_test spawned each test with start_new_session=True and no stdout/stderr arguments. The spawned `bash -c "<test> > out 2> err"` wrapper therefore inherited the write end of that pipe, since the redirect binds only the command the wrapper execs. A test that escaped into its own session outlived the worker, so `ts` never saw EOF, `tee` never exited, the top-level bash never exited, and Shell.run blocked in proc.wait() plus both reader joins until the watchdog fired. Pass explicit sinks at the spawn site. The test's own output is already redirected to the per-test .stdout/.stderr files and read back from them by process_result_impl, so nothing is lost. The wrapping shell's stderr is appended to the .stderr artifact rather than discarded, so shell level errors that happen before the redirect takes effect (a bad redirect target, a syntax error) stay visible. Detaching only stdout is not sufficient: Shell.run joins the stderr reader too, so an orphan holding fd2 alone still blocks for its whole lifetime. Also run `clickhouse-test --cleanup` in run_tests' finally, so a test that escaped stops consuming the machine and querying the server during teardown. The finally placement covers every invocation, which matters because bugfix validation calls run_tests once per build type. Measured on the failing shape, with no timeout or watchdog configured: 12.03s -> 0.03s. A local batch of 211 stateless tests gives byte-identical statuses and failure reasons with and without the change. This does not fix the underlying runner-wide failures tracked in ClickHouse#108689 and makes no claim about OOM. It makes that class attributable by letting the diagnostic stages run. The claim covers the observed connection-refused shape, where the server had already terminated; a wedged, alive-but-unresponsive server is out of scope. Related: ClickHouse#108689
The previous commit sent it to the test's `2>` target. That file is the wrong destination for two measured reasons. It is truncated by the test's own redirect, which opens it after the sink is already open, so a message the shell emits before that point is written and then destroyed. Measured with `LC_ALL` set to a bogus locale: the shell warns and the file ends at 0 bytes. And it is read back as `stderr`, where it decides the verdict. Non-empty `stderr` is itself a FAIL, `<Fatal>` and `Connection refused` force `SERVER_DIED`, and the string reaches the retry matcher. A job-status line quotes the whole command, and `MESSAGES_TO_RETRY` holds substrings as generic as `No such file or directory`, so a shell reporting an unopenable redirect target could retry a deterministic failure up to `MAX_RETRIES` and report it as flaky. Only the shell's own messages move; the two emitted after the fork with the redirect already installed (`Permission denied` and `No such file or directory` from a failed exec) are the test's stderr and are unaffected. The relocated text is appended by `process_result`, which runs after the retry check, so it stays visible in the job log without entering the verdict path. `hide_db_name` scrubbing covers the new file, since those lines quote `--database=`. An empty one is removed right after `proc.wait()`: `Popen` creates it whether or not the shell writes, and the existing cleanup only runs for a passing test, so without this a 220-test batch left 13283 empty files in the suite's tmp dir. The tests now pin the spawn's argument VALUES rather than the presence of the keyword names, which a mutation to `stdout=sys.stdout` satisfied while restoring the wedge, and resolve the sink through the local assignment so a decoy `open` of the same path cannot stand in for it. The path is derived in both entry points, next to `fatal_sanitizer_prefix` and for the same reason: `test_expect_debuglog_separation.py` drives them on namespace stubs that carry only the artifact paths.
Internal second-model review (2 rounds, 0 open blockers)I put this change through two rounds of independent review before opening it. Round 1 bounced it Round 1
Relocating a parent-side line into
💡 Two nits I disagreed with, on evidence: a request to duplicate the reap proof (already covered Round 2I re-derived the mechanism independently rather than re-reading the round-1 account: a live Both fixes were then checked by mutation against the real file, each arm run, tree restored after I also stressed the timing threshold, since a 3 s bound on a ~0.02 s operation is the sort of Two properties worth naming because they were easy to get wrong. The empty-file removal cannot |
Pre-PR validation gate (click to expand)
Validation detail: a real local batch of 220 stateless tests ( One deliberate behavioral change: with |
|
cc @maxknv @azat, could you review this? |
|
Workflow [PR], commit [df5f3eb] Summary: ✅ AI ReviewSummaryThis PR fixes the stateless-job hang by detaching the per-test wrapper shell from the runner pipeline, routing the wrapper shell's Final Verdict
LLVM Coverage ReportMeasured on commit df5f3eb.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +183 lines in 51 files (-130 lines lost coverage) · Details |
CI finish ledger — 50efca4Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
All 175 check-runs are complete: 80 success, 94 skipped, 1 failure. Neither row is caused by this diff. The The Session id: cron:our-pr-ci-monitor:20260803-033000 |
Master removed the `ci/tests` suite and the `CI Tests` job that ran it (`5b3d66b1a66`, `8ff3720644b`), then removed a file a branch cut before that had re-created (`5e8bf203b14`). `.claude/CLAUDE.md` now asks for a throwaway check of a CI-script change rather than a committed test. This branch was cut before the removal, so the two files it adds there are dropped: nothing would run them, and keeping them would re-open that decision. The one conflict is in `run_tests` in `ci/jobs/functional_tests.py`: master changed how `outer_timeout` is derived, and this branch wraps the `Shell.run` call below it in a `try`/`finally`. Kept master's derivation and the `finally`. The fix itself is unaffected; what is lost is its CI-side unit coverage, which has no runner upstream any more. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A non-passing test whose wrapping shell wrote a job-status line (for example a test killed by a signal) keeps its `.stderr-wrapper` file next to its `.stdout` and `.stderr`, like those two. When `clickhouse-test` runs from the repository, that directory is `tests/queries/0_stateless`, where `.stdout` and `.stderr` are ignored but the new file showed up as untracked. Add it next to `*.stderr-fatal*`, the pattern the sanitizer report files got for the same reason. Co-Authored-By: Claude Opus 5.5 <[email protected]>
It names the function, not a call, which `.claude/CLAUDE.md` asks to write as `f`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Superseded by #112265 (merged 2026-09-27), which gives the per-test wrapper its own stdout and stderr, and #113393 (merged 2026-10-01), which reaps the groups the abort path orphans. Re-measured on current master's runner: with What is left here (a separate |
Related: #108689
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Stateless tests (amd_asan_ubsan, distributed plan, parallel)onthis report
lost its server around test 4291/12235, then produced no output for 1 h 55 m until the 9000 s
watchdog killed it. No test failed and no server log was uploaded.
Root cause:
clickhouse-testspawned each test withstart_new_session=Trueand nostdout/stderr, so thebash -c "<test> > out 2> err"wrapper inherited its own fd1/fd2(the redirect binds only the command it execs). Under CI those are the write end of
clickhouse-test | ts | tee, so a test escaping into its own session kepttsfrom seeing EOF:teenever exited,proc.wait()never returned, and the job was SIGKILLed beforeCHECK_ERRORSandCOLLECT_LOGS. That is also why the shape carries no crash trace orsanitizer report: those were never produced, so their absence says nothing about the server
(1 report link, versus 5 for the sibling job).
The spawn now passes explicit sinks: 12.03 s -> 0.03 s, with no timeout configured. Both
descriptors matter, since
Shell.runjoins both reader threads. Nothing is lost: the test's ownoutput already went to the per-test
.stdout/.stderrfiles, and the wrapper writes nothing tofd 1. Its fd 2 carries job status (a killed test, a bad redirect target, a syntax error) and
gets a
.stderr-wrapperfile of its own, reported after the retry check rather than sharing thetest's
2>target, which the test truncates and which is read back as the verdict. The job alsoruns
clickhouse-test --cleanupin afinally.This does not fix #108689 and makes no claim about OOM; it makes the class attributable by
letting log collection and the dmesg OOM check run. A wedged but alive server is out of scope.
A local batch of 220 stateless tests gives identical statuses and reasons.
Workflow [PR]
Sync PR [sync-upstream/pr/113039]