Repository navigation
Bound the stress job's three dataset preparation INSERTs - #117626
Conversation
`Stress test (amd_tsan)` on ClickHouse#117132's previous head burned its entire 10800 s budget inside dataset preparation, before any stress test ran, and produced zero test rows and no stacks to root-cause from. Job 99232249984, sha 36daaa0: `Using azure storage policy` at 08:47:41 (that echo exists only in the `RANDOM % 3` branch of the policy selector, so the policy was drawn randomly), the `INSERT INTO test.hits_s3` traced at 08:47:42, then 176.1 minutes of complete log silence until praktika's `WARNING: Timeout exceeded [10800]` and `exit code [-15]`. The CIDB row is `check_status = error`, `check_duration_ms = 10812856`, `test_name` and `test_status` both empty. There are two causes and this commit addresses only the second. `--max_execution_time` is enforced cooperatively: `ProcessList` registers the query with `CancellationChecker::appendTask`, whose `cancelTask` calls `QueryStatus::cancelQuery(CancelReason::TIMEOUT)` from a background thread, so the deadline is raised out of band but ends the query only where the query's own threads observe it. A thread parked in a blocking call never observes it. Which frame was parked is unknown, because the job was TERM-killed and left no stacks, so I am not touching `src/` and not naming a frame. It cost the whole job budget because nothing bounded those statements in wall-clock time and nothing captured state when they overran. ClickHouse#115585 added `timeout --verbose --signal=TERM --kill-after=60 <N>` per statement to `ClickHouseService.prepare_stateful_data`, but that method is called only from `ci/jobs/functional_tests.py`; the stress job runs `stress_runner.sh` in docker instead, so its prep was never covered. This closes that gap with the same mechanism and adds the stack capture that makes the first cause reachable next time. It does not paper over that cause: today an occurrence yields no stacks and no rows, so the cause is unreachable by construction, and the capture is a prerequisite for an engine fix rather than a substitute for one. The bound is 900 s, derived from the deadline the statement itself declares plus 300 s of grace for client start, connect, handshake and the final commit. The worst single statement measured is 187.1 s and the worst three-statement total 429.8 s, so a healthy run cannot reach 900 s unless the server-side deadline has already failed to fire, which is the condition worth reporting. The firing predicate is the conjunction of the exit code and `timeout`'s own diagnostic, because neither half identifies an expiry alone. `clickhouse-client` returns the server's error code (`programs/client/Client.cpp:483`) and `M(124, INCORRECT_ELEMENT_OF_SET)` exists, so 124 is also an ordinary query failure, and 137 is any SIGKILL death including an external or OOM kill. Symmetrically, GNU `timeout` prints the identical `sending signal TERM to command` line when it merely forwards a signal it received, exiting 143. That shape is not hypothetical: it is how the job on record ended. praktika's own job timeout prints `WARNING: Timeout exceeded [10800] for [2254]` and then sends SIGTERM to the whole process group (`ci/praktika/utils.py:1087-1098` and `:1184-1188`, over the group created at `:1148`), which docker forwards into the container. So a marker-only predicate would dump stacks, force-stop the server and fail the job during a cancellation, extending exactly what this change exists to shorten. The marker substrings are deliberately quote-free because `timeout` renders the command name in locale-dependent quotes, curly under `C.UTF-8` and straight under `LC_ALL=C`, which also pins the message text. On a proven expiry the script reports a named `FAIL` row, dumps the server's threads and stops, rather than preparing data against a wedged server. That turns an opaque job-level timeout into a named failed sub-result, and it is the in-tree idiom: `upgrade_runner.sh:161-167` and `stress_tests.lib:319-322` both bound a statement, dump stacks to the same `gdb.log` and `clickhouse stop --force`. Exiting loses nothing, because `stress_job.py` runs `collect_cores`, the OOM probes, `fatal.log` generation and `process_results` unconditionally after the docker exit, and both `/test_output` and `/var/log/clickhouse-server` are volume mounts. Only a proven expiry exits. Any ordinary non-zero exit keeps today's `set +e` behaviour, which the surrounding comment already documents as intended. Only those three statements are bounded. `create_tpch.sh`, run earlier at `stress_runner.sh:70`, loops eight `INSERT ... SELECT FROM s3()` statements that are also unbounded in wall clock, and `create.sql` and `create_tpcds.sh` attach their tables over a web disk and insert nothing. I left TPC-H alone on purpose: those eight declare no `max_execution_time`, so there is no unenforced limit there to restore, they read from public buckets where a bound would newly fail jobs that today merely run slowly, and they sit in the `set -e` region rather than the `set +e` region whose continue-on-failure semantics this change is deliberately narrower than. Bounding them is a separate change if it is wanted. Related: ClickHouse#117132 (comment) Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model reviewAn independent model reviewed this change against the ClickHouse review skill, and I reviewed it cold
After those corrections a second independent round returned no findings, and I re-read each replaced Also verified rather than assumed, since each one could have hidden a defect: both |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20260902-045700 |
|
Workflow [PR], commit [c8a0a1c] Summary: ✅ AI ReviewSummaryThis PR adds a wall-clock Final Verdict✅ No new findings. |
|
cc @PedroTadim, could you review this? It bounds the stress job's three dataset-preparation INSERTs with |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Bound the stress job's three
test.hits_s3/test.hits/test.visitspreparationINSERTs in wall-clock time, and dump the server's thread stacks when the bound fires.Description
Related: #117132 (comment)
Failing job: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=117132&sha=36daaa0b2b59eae8c3ddfbd72137c5235282cfb8&name_0=BackportPR&name_1=Stress%20test%20%28amd_tsan%29
Stress test (amd_tsan)burned its whole 10800 s budget inside dataset preparation, before any stress test ran, leaving zero test rows and no stacks. Job99232249984, underazure_cache: theINSERT INTO test.hits_s3traced, then 176 minutes of silence until praktika'sTimeout exceeded [10800].Two causes.
The statement never returned.
--max_execution_timeis enforced cooperatively:CancellationCheckerraises the deadline out of band, ending the query only where its threads observe it; a thread parked in blocking I/O never does. Which frame was parked is unknown: theSIGTERMleft no stacks, so this PR does not touchsrc/.It cost the whole budget because nothing bounded it in wall clock and nothing captured state. Bound each statement of the stateful data preparation #115585 added that bound to
prepare_stateful_data, but the stress job never calls it:stress_job.pyrunsstress_runner.shinstead.Same mechanism:
timeout --verbose --signal=TERM --kill-after=60 900per statement, the 600 s declared deadline plus 300 s of grace, against a worst measured 187 s. On a proven expiry it writes a namedFAILrow, dumps the server's threads togdb.log, force-stops and exits, mirroringupgrade_runner.sh:161.An expiry needs the exit code AND
timeout's own diagnostic:clickhouse-clientexits with the server's error code, so 124 is also an ordinary error, and a forwarded signal prints the same TERM line but exits 143. A 9-arm harness over the shipped helper covers both expiry shapes and five non-expiry ones, both directions.Only those three are bounded.
create_tpch.shruns eight earliers3()INSERTs, but they declare no deadline, so there is no unenforced limit to restore; bounding them is a separate change.Behaviour change: a wedge becomes a named red with stacks, bounded by 900 s plus the 30 min dump, not an opaque 10800 s timeout with nothing to diagnose. Ordinary failures keep today's
set +ebehaviour.Workflow [PR]
Sync PR [sync-upstream/pr/117626]
Workflow [PR]
Sync PR [sync-upstream/pr/117626]