Repository navigation
Do not fail the Stress test job when the server stops during the shutdown grace period - #116841
Conversation
…down grace period
stop_server writes "Warning: server did not stop yet" when
`clickhouse stop --do-not-kill` times out, terminates gdb, waits 60 seconds
and then rechecks the pid:
kill -s 0 "$pid" || return
A bare `return` propagates the last command's status, which on this branch is
the `kill -s 0` that has just failed because the process is gone. So the branch
whose own comment reads "The server could finally stop while we were
terminating gdb" returns 1 exactly when the server did stop. The polarity is
inverted: the good outcome returns failure, while the bad outcome falls through
to `clickhouse stop --force` and returns 0, reporting through the
"Possible deadlock on shutdown" row in test_results.tsv.
stress_runner.sh runs under `set -e` and calls stop_server bare at line 330, so
the non-zero status aborts the script and stress_job.py appends a job-level
"Check failed with exit code 1" row. Two consequences: the check invents a
failure on a run where shutdown completed, and because the abort is at line 330
the steps below it never run, so check_logs_for_critical_errors never applies
its "S3_ERROR No such key thrown" and "Lost forever for SharedMergeTree"
detectors and dmesg.log is not collected.
Measured over 30 days in the CI database, grouped per (pull request, commit,
check) among Stress test runs carrying the warning row: 5 groups over 5 pull
requests (1 on master) have no "Possible deadlock on shutdown" row and failed,
while 30 groups over 27 pull requests (2 on master) have that row and passed.
The table is perfectly anti-diagonal over all 35 groups, so the behaviour is
deterministic rather than flaky. It also states the contract this function is
meant to satisfy: stop_server exits 0 once the server is no longer running, and
shutdown problems travel as test_results.tsv rows rather than as an exit status.
upgrade_runner.sh:349 reaches the same line with check_hang defaulted to true
and is fixed by the same change, with no observed occurrence in 30 days.
upgrade_runner.sh:170 passes check_hang=false and takes the other branch.
Validated by driving the extracted function text with stubbed clickhouse, gdb,
pidof and ts in three fixtures: the server exits inside the grace window, it
outlives the window, and it is already gone before the first check. The pre-fix
text fails the first and third with the caller aborting, the fixed text passes
all three, and replacing the guard with an unconditional `return 0` fails the
second, which is what keeps the deadlock report honest.
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings), which read My own cold review of the resulting tree, done before reading the author's evidence, raised two
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20260828-081700 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20260828-075300 |
|
Workflow [PR], commit [fca818f] Summary: ✅ AI ReviewSummaryThis PR fixes Final Verdict
|
|
cc @maxknv, could you review this? |
CI finish ledger -
|
| Check / test | Reason | Owner / fixing PR |
|---|---|---|
Stress test (amd_msan) / Logical error: Shard number is greater than shard count: shard_num=2 shard_count=1 cluster=test_cluster_one_shard_three_replicas_localhost (STID 5066-457d) |
a parallel-replicas shard number is validated against a cluster that did not produce it, aborting at src/Interpreters/ClusterProxy/executeQuery.cpp:788 in prepareClusterForParallelReplicas under executeQueryWithParallelReplicas. Trunk defect, first seen 2026-08-03, 60 CIDB rows over 46 distinct PRs with 8 true-master rows in 30 days, and this PR's entire diff is one shell library, tests/docker_scripts/stress_tests.lib |
fixing PR #113589 (mine, open) |
The owner is exact rather than same-area: #113589 "Bind the parallel replicas shard scope to the
cluster that produced it" rewrites that very function (its diff carries the hunk
@@ -767,16 +850,16 @@ static std::pair<ClusterPtr, size_t> prepareClusterForParallelReplicas),
which is the frame that aborts here.
This head also supplies its own control: two runs executed the identical tree and disagreed on this
leg, failure in one and success in the other, so the red is state or timing dependent rather
than tree dependent. Nothing in a change to the stress harness's shutdown handling can reach a
cluster-scope assertion in the server, and the signature predates this branch by 25 days.
Session id: cron:our-pr-ci-monitor:20260828-100000
ba766af
Related: #109225
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
stop_serverintests/docker_scripts/stress_tests.libreturns a failing status on thebranch that means the server shut down cleanly, just slowly.
After
clickhouse stop --do-not-killtimes out it writesWarning: server did not stop yet,terminates gdb, waits 60 seconds and rechecks the pid:
A bare
returnpropagates the last command's status, here thekill -s 0that just failedbecause the process is gone. So the branch whose own comment reads "the server
could finally stop" returns 1.
stress_runner.shruns underset -eand callsstop_serverbare at line 330, so the script aborts and the job becomes
Check failed with exit code 1.Two costs: the job invents a failure on a run where the server did stop, and the steps below
line 330 never run, so
check_logs_for_critical_errorsnever applies itsS3_ERROR No such key thrownand lost-SharedMergeTree detectors.Over 30 days, among
Stress testruns carrying the warning row (grouped per PR, commit andcheck): 5 groups / 5 PRs (1 on master) lack a
Possible deadlock on shutdownrow and failed;30 groups / 27 PRs (2 on master) have it and passed. Perfectly anti-diagonal: deterministic,
not flaky.
upgrade_runner.sh:349reaches the same line and is fixed with it.Reference run (
arm_debug):https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109225&sha=b339930e18c91cefedc528a8370375ce7a2da4e9&name_0=PR&name_1=Stress%20test%20%28arm_debug%29
No test added: this is a docker-only bash function reached through hardcoded absolute paths,
and
ci/tests/is being removed. I validated locally by driving the real function text withstubbed
clickhouse,gdb,pidofandtsin three fixtures (server dies inside the gracewindow, outlives it, already gone); reverting the token reddens the first and third, an
unconditional return reddens the second. The remaining detector is CI itself: a
Stress testrun carrying the warning row and no
Possible deadlock on shutdownmust be green.Workflow [PR]
Sync PR [sync-upstream/pr/116841]
Version info
26.9.1.267(included in26.9and later)