Repository navigation
Conversation
The hung-check probe in `do_run_tests` sat directly inside the `while processes: sleep(0.1)` loop with no interval gate, unlike the sibling memory check 40 lines above which is gated on `MEMORY_CHECK_INTERVAL`. The comment said "Periodically"; there was no period. And `check_server_liveness` runs its whole 10-attempt, up-to-165s retry loop synchronously. So a healthy hours-long run issued `SELECT 1 /*liveness check*/` roughly every 0.1s (72001 probes on a modelled 3h run), putting continuous pointless load on the very server whose saturation is being diagnosed. And when the server was slow the parent blocked inside the probe for the full 65 to 165s and re-entered immediately on return, so starvation was effectively continuous (92.7% blocked duty cycle measured). While blocked the parent ran neither the memory-pressure worker shed, which is the one mechanism that could relieve the pressure, nor the `args.stop_time` deadline check, nor `stop_testing` handling. The verdict itself is correct and is not made more tolerant. Across 14 CI job logs the gap to verdict is bimodal at 63-69s and 165-166s, exactly the probe's own 10-attempt budget, zero log lines fall inside the probe window in 14 of 14 runs, and the progress index advances by exactly +1 across the verdict. The `[ OK ]` lines after the verdict are recovery during lldb collection. This changes only the probe's scheduling. Four caller-side changes; the callee is untouched. Interval-gate the probe at 30s reading a fresh `time()`; pass `max_retries=1` and reproduce master's 10-attempt schedule as loop-owned state; gate the benign-deadline block on a liveness confirmation taken at or after the deadline; and add a terminal drain after the loop that finishes a pending failure sequence and claims the deadline. The last two are not cosmetic. Splitting the retry window lets the loop reach the deadline block between two failing probes, and lets the loop exit while a failure sequence is pending because the workers finishing ends it. Master satisfied both invariants only incidentally, since its single blocking call spanned the whole window and so could not be cut short. Without the drain a death after the last probe escapes the check and the run reports a generic failure, not `Server died`. Both abort budgets are preserved (65.1s to 66.0s, 165.1s to 166.0s), healthy-run probes drop from 72001 to 359, and the verdict string is kept byte-identical because CIDB queries key on it. Across a 312-scenario stall sweep in both memory regimes there are no cases where this aborts and master does not, and none where it aborts earlier; a 1314-scenario drain sweep also finds none. Two residuals, both conservative: detection latency rises by up to 30.4s against the job's own margin of at least 900s, and 156 of 1314 drain-sweep aborts are not reproduced, every one a case where the stall barely exceeds master's own window and the server in fact recovered, with no permanent death missed. Adds ci/tests/test_hung_check_schedule.py (25 tests, structural plus behavioural on a fake clock), where there was previously no coverage of the hung-check schedule at all.
Review round 1 on the hung-check test suite. Three defects in the test harness, none in the production change. The harness ran `do_run_tests`' graceful-deadline paths, which install `SIGTERM = SIG_IGN` process-wide (tests/clickhouse-test:5220, :5349) and never restore it. `run_loop` restored six module globals but not the signal disposition, which is not a module global. `SIG_IGN` survives exec (CPython's `_Py_RestoreSignals` resets only SIGPIPE/SIGXFZ/SIGXFSZ), so the leak stopped every later test in the same pytest process from being able to SIGTERM a child: TeePopen terminates via `os.killpg(pid, SIGTERM)` and the three `test_teepopen_timeout_kills_process` cases assert `rc == -SIGTERM`. `run_loop` now captures and restores the disposition, and a regression test asserts it is unchanged across a run that really takes the SIG_IGN path. The harness also kept the real `multiprocessing.Manager`, which forks a server process and binds an AF_UNIX listener under `$TMPDIR` against a 108-byte path cap, so under a long `TMPDIR` all sixteen behavioural tests died before `do_run_tests` ran. The IPC bought nothing: the production code only calls `.list()` and `.extend()` on the result and the fake workers never read the queue. A plain-list stand-in replaces it; `Value` and `Event` need no server process and are kept. Finally, the suite asserted the schedule arithmetic but not the property the change exists for: that the parent keeps running the memory-pressure worker shed, the deadline check and stop handling between failed probes. Three tests now pin it, including that `workers_to_shed` is actually incremented rather than the message merely printed. 25 tests to 29. Suite wall-time 5.0s to 2.5s, whole ci/tests 139s to 46s. No change to tests/clickhouse-test.
Internal second-model review (2 rounds, 9 findings, click to expand)Before opening this I ran two independent review rounds against the change: a cold read of the Round 1❌ blocker - the test harness leaked
💡 Three nits on the PR text, all corrected: a self-contradictory test count, an unverified claim Round 2The second model returned no findings, having read the full new test file, the complete My own cold read found three problems in the PR text rather than the code, all fixed here: the 💡 One nit noted and not fixed: there are two ✅ Verified independently rather than taken on trust: the 65 s back-off ladder sums exactly; |
Pre-PR validation gate (click to expand)
Decisive result: across a 312-scenario stall sweep in both memory regimes there are 0 cases where this branch aborts and master does not, and 0 where it aborts earlier; the drain-specific sweep over 1314 scenarios also finds 0. Two residuals are disclosed in the PR body rather than claimed away: detection latency rises by up to 30.4 s (against the job's own >=900 s margin), and 156 of 1314 drain-sweep aborts are not reproduced, every one a case where the stall barely exceeds master's own window and the server in fact recovered (0 permanent deaths missed). Session id: cron:clickhouse-review-slot-8:20260729-044501 |
|
cc @leshikus - could you review this? It interval-gates the |
|
Workflow [PR], commit [44b7759] Summary: ❌
AI ReviewSummaryThis PR moves the hung-check retry window out of Findings
Final VerdictNeeds changes: keep the existing inline thread open and fix the terminal-drain misclassification before merge. |
| # otherwise a death after the last successful probe would leave the run | ||
| # reporting a generic failure instead of `Server died` (master's single | ||
| # blocking call spanned the whole window and so could not miss it). | ||
| if args.hung_check and not stop_testing.is_set(): |
There was a problem hiding this comment.
Once last_hung_check_ok >= args.stop_time has already been recorded in the loop, this unconditional drain probe can still overturn the already-confirmed benign deadline if the server disappears after the last worker exits. Using the new harness, run_loop(alive=lambda t: t < 200.11, deadline=200.0, workers_done=200.0) produces (200.10, True) from the deadline-triggered probe, then the drain immediately re-probes at 200.15, starts a fresh failure ladder, and eventually returns server-died. At that point the run has already proved the deadline condition; the drain should short-circuit to GLOBAL_TIME_LIMIT_EXIT_CODE instead of re-checking liveness, and a focused regression case should pin this race.
CI finish ledger — 6b731dfEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose
Session id: cron:our-pr-ci-monitor:20260729-164745 |
CI finish ledger - 44b7759Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Not PR-caused: this PR changes only Session id: cron:our-pr-ci-monitor:20260828-020000 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
The hung-check probe in
do_run_testssits inside thewhile processes: sleep(0.1)loop with nointerval gate, unlike the sibling memory check 40 lines above gated on
MEMORY_CHECK_INTERVAL. Thecomment says "Periodically"; there is no period. And
check_server_livenessruns its whole10-attempt retry loop synchronously. So a healthy 3 h run issues ~72000
SELECT 1 /*liveness check*/probes at the very server whose saturation is being diagnosed, and while the server is slow the
parent blocks 65 to 165 s and re-enters at once (a 92.7% blocked duty cycle), running neither the
memory-pressure worker shed - the only mechanism that could relieve it - nor the deadline check, nor
stop_testing. The verdict itself is correct and is not made more tolerant: the gap to verdictmatches the probe's own budget exactly across 14 CI job logs, and 32 of 166 hits in 45 days had no
server.
Only the scheduling changes, in four caller-side edits;
check_server_livenessis untouched:interval-gate the probe at 30 s on a fresh
time(); passmax_retries=1and reproduce master's10-attempt back-off as loop-owned state, bounding each poll by one socket timeout; require a liveness
confirmation at or after the deadline before claiming it; and drain a pending failure sequence past
the loop. The last two matter because splitting the window lets the loop reach the deadline block
between two failing probes, and exit mid-sequence when the workers finish - invariants master held
only incidentally.
Both abort budgets are preserved, the verdict string is byte-identical because CIDB keys on it, and a
312-scenario sweep finds 0 cases where this aborts and master does not. Detection latency rises
by up to 30.4 s against the job's own at-least-900 s margin. The new
ci/tests/test_hung_check_schedule.pydrives the realdo_run_testson a fake clock: 29 tests, 14failing on the pristine script.
Measurements, residuals, mutation matrix, and the #106385 interaction
A fake-clock harness drives the real
do_run_teststhroughrunpywith patched globals, comparingpristine master against this branch. A real-server repro would need a multi-minute stall under 19-way
load on an instrumented build.
The instant-refusal band matters most: that is where the 32 hits with no server process land. An
earlier design of mine aborted those at 150 s instead of 65 s, 2.3x slower to report a real death, and
I rejected it for that reason. The 312-scenario sweep also finds 0 aborting earlier, and a
1314-scenario drain sweep 0 spurious aborts. Second residual: 156 of those 1314 are not reproduced,
every one a stall barely exceeding master's own window where the server recovered, so no permanent
death is missed.
33-mutant matrix, predicting the failing test before each run: 31 killed by a named test and 1 (M21)
by the suite failing to terminate, itself a detected defect. The one survivor guards against claiming
the deadline twice and is unreachable because the loop sets the flag together with
stop_testing,never cleared; rather than delete it I pinned the facts that make it so.
#106385 (@ PedroTadim, open) edits
check_server_livenessitself, addingif os.path.isfile(_RESTART_MARKER_FILE) and max_retries < 30: max_retries = 30inside the retryloop, so a
max_retries=1call would silently become a 30-attempt call during a stress restart -exactly the per-poll bound this PR relies on. Complementary, but whichever lands second should confirm
the one-attempt contract still holds. Nothing to do on that branch.