Repository navigation
Bound each stress teardown attempt so a wedged server cannot burn the job budget - #112927
alexey-milovidov merged 3 commits into
Conversation
… job budget `stop_server` retries `SYSTEM STOP DISTRIBUTED SENDS` up to 30 times before `clickhouse stop`. bada962 added `--receive_timeout=10` to cap each attempt at 10 s, because at the 300 s default the loop can burn 30 x 300 = 9000 seconds and consume the whole CI job timeout. The intent was right, but the flag is inert on this path, so the loop is still unbounded today. The client sets the socket to `handshake_timeout` before `sendHello` (src/Client/Connection.cpp:264-265) and swaps in `receive_timeout` only once the handshake completes (:352-353, "Now that the handshake is complete, use the regular timeouts"). The client CLI's own handshake default is DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC * 1000 = 300000 ms (src/Client/ConnectionParameters.cpp:177), not the 10000 ms of the `handshake_timeout_ms` setting. So against a server that accepts the TCP connection but never answers Hello, `receive_timeout` is never reached. Measured against a socket that accepts and never writes: `--receive_timeout=10` takes 300.4 s and reports `300000 ms`, `--receive_timeout=3` also takes 300 s and reports `300000 ms`, and `--handshake_timeout_ms=10000` takes 10.2 s and reports `10000 ms`. Two different `receive_timeout` values producing the same elapsed time is the proof that the flag does not apply here. Pass `--handshake_timeout_ms=10000` so the common case fails in 10 s with a diagnostic, and wrap the attempt in `timeout -s KILL 15` so the bound is unconditional: the flag alone still leaves a mid-send stall on `send_timeout` (300 s, not passed here) and a DNS or TLS wedge on nothing at all. The wrapper is the shape 2f787c6 used for this same failure mode in the PGO readiness probe, and `timeout` is already used in this file and in upgrade_runner.sh, so the image is unchanged. 10000 ms is the `handshake_timeout_ms` setting's own default (src/Core/Settings.cpp:402) and one third of the server's own handshake ceiling (src/Core/ServerSettings.cpp:1405), so it sits well above a healthy handshake under thread fuzzer and well below the point where the server itself would have dropped an unauthenticated connection. All 30 iterations are kept, so the worst case goes from 9000 s to 450 s. This is a redistribution of patience rather than a reduction: a server that is merely slow to stop still gets 30 attempts. This does not fix the server-side stall and is not intended to. When the loop consumes the job budget the runner is killed before the artifact-upload step, so `clickhouse-server.stress.log.zst`, the one file that could identify the stalled threads, is never uploaded. Bounding the loop converts a lost job into a job that reports the stall with its logs attached. The new test runs the loop text verbatim, extracted between the BEGIN/END markers, against a mock client, in the shape of the existing ci/tests/test_logs_cluster_probe_loop.py. It asserts that the loop finishes against a wedged mock, that the pre-fix text does not finish under the same budget, that a mock recovering on the 6th attempt is still retried, and that the handshake bound reaches the client's argv. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Internal second-model review (0 blockers, 0 majors, 2 nits) — click to expandBefore opening this PR I ran an independent cold review of the resulting code (without the
Things I checked that did not produce findings, since they are the parts most worth doubting:
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-46:20260801-143400 |
|
cc @maxknv, could you review this? The stress teardown loop passed |
|
Workflow [PR], commit [4d9c924] Summary: ✅ AI ReviewSummaryThis PR updates Final Verdict✅ Approve. No new blockers or majors. |
CI finish ledger - a3fb630Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task CI is terminal on this head (174 check-runs, 0 queued or in progress, both aggregators green). Three failures, all one signature:
Session id: cron:our-pr-ci-monitor:20260801-203000 |
|
Fixing PR for the pre-auth That PR reapplies #110760 (reverted in #112935) together with the fix: |
`ci/tests/test_stress_stop_server_bounded.py` can never run. The `CI Tests` job that ran `pytest` over `ci/tests/` was removed in 8ff3720 along with `JobConfigs.ci_tests` and the `ci_tests` lane of the generated workflow, and the suite itself was emptied by ClickHouse#115650. Nothing in the tree invokes pytest over `ci/` today: the only remaining `ci/tests` references are the `example_1` cache samples in ci/praktika/cache.py, and a file landing there is deleted again (2c10dbc). So the file was a guard that no check could turn red. The BEGIN/END marker comments existed only so that test could extract the loop text verbatim, so they go with it. The invariant comment stays: it is why the `timeout` wrapper is load-bearing rather than belt-and-braces.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #108775 (its failing
Stress test (arm_tsan)job, and the request for a separate fix PR)This completes bada962, whose message states the goal:
stop_server'sSYSTEM STOP DISTRIBUTED SENDSloop could burn 30 x 300 = 9000 s. It added--receive_timeout=10, but that flag is inert here, so the loop is still unbounded.The client holds
handshake_timeoutuntilsendHellocompletes (Connection.cpp:264-265) andswaps in
receive_timeoutonly afterwards (:352-353); the CLI's handshake default is300 000 ms (
ConnectionParameters.cpp:177), not the setting's 10 000 ms. Against a server thataccepts TCP but never answers Hello,
receive_timeoutis therefore never reached: measured,--receive_timeout=10and=3both take 300 s and report300000 ms, while--handshake_timeout_ms=10000takes 10.2 s.I pass
--handshake_timeout_ms=10000so the common case fails in 10 s with a diagnostic, andwrap the attempt in
timeout -s KILL 15so the bound is unconditional, since the flag aloneleaves a mid-send stall on
send_timeout, still 300 s.timeoutis the shape used for this in2f787c6. All 30 iterations are kept: worst case 450 s, not 9000 s, so patience is
redistributed, not reduced.
This does not fix the server-side stall and is not offered as one: a job that now hits the
10800 s cap and dies before uploading anything will instead report the stall with its logs
attached. Its "server did not stop yet" rows appear 91 times in 2026-08-11..2026-09-09, 84% on
TSAN variants, 9 on master.
Validation is local, not in-tree: against a mock client the loop finishes on a wedged server
while the pre-fix text does not, and a server recovering on the 6th try is still retried. A
pytest file under
ci/testscarried this at first; I dropped it, because the job that ranpytestthere was removed in 8ff3720. Changing the 300 s client default would beuser-visible, so I left that out.
Workflow [PR]
Sync PR [sync-upstream/pr/112927]