Repository navigation
Print the stack trace of a stuck worker in FunctionsStress.stress - #126137
alexey-milovidov merged 2 commits into
Conversation
A stuck-worker report printed only the query of the step the worker was in, so a stall whose location does not follow from the query could not be located from CI. Since 2026-10-15 the asan_ubsan function_prop_fuzzer job fails this way on `range` in about 3% of runs, with queries that take well under a second on their own. On stuck detection the main thread now sends STACK_TRACE_SERVICE_SIGNAL to the first stuck worker while still holding its mutex, so the worker cannot move to another step between the copy of `operation` and the capture. A handler owned by the test copies StackTrace(ucontext) for that one thread (identity check on pthread_self, as on the macOS path of system.stack_trace) and sets an atomic; the main thread waits up to 10 s, then prints one line per frame with the ASLR-independent offset from tryResolveAddress, for llvm-symbolizer against the job's unit_tests_dbms, and the demangled name from SymbolIndex::instanceIfInitialized()->findSymbol. StackTrace::toString is not used: it takes the stack-trace cache locks and SymbolIndex::instance, which the stuck thread may hold. The symbol index is built on the main thread at test start, before any worker exists, so names resolve even when no exception has built it yet. The handler stays installed for the rest of the process: the signal is not in HandledSignals::handled_signals, so HandledSignals::reset never sets it to SIG_DFL, and a delivery after the timeout fails the identity check and returns. Skipped where hasAsyncSignalSafeUnwind() is false (TSan), and on non-Linux builds; those keep the report with only the new iteration age. Co-Authored-By: Claude Opus 5.5 <[email protected]>
For a frame outside unit_tests_dbms, StackTrace::tryResolveAddress returns an offset inside the shared object it names, so a bare offset was misleading. Append the object the same way the fatal-signal handler does (writeResolvedAddress in SignalHandlers.cpp): " in <object>" for another loaded object, " in <unknown>" for an unmapped address. StackTrace(ucontext) returns an empty trace when the unwinder faults, which was printed as a stack header with no frames. Report it as a failed unwind. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (2 rounds: 2 fixed, 1 declined, 0 open)
Round 2 (after the fixes): no findings. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261015-181800 |
|
cc @Algunenano, could you review this? When |
|
Workflow [PR], commit [0bb0a2f] Summary: ✅
AI ReviewSummaryThe PR adds iteration age and a bounded stack capture for the first stuck worker in Missing context / blind spots
Final VerdictStatus: ✅ Approve. No review changes required. |
a72cb3a
…ryResolveAddress` ClickHouse#126039 made `StackTrace::tryResolveAddress` return `ResolvedAddress` instead of `std::optional<ResolvedAddress>`, while ClickHouse#126137 started using it as an optional in `gtest_functions_stress.cpp`, so master does not compile `unit_tests_dbms`. The same change as ClickHouse#126269, to unblock CI here. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126134&sha=latest&name_0=PR&name_1=Build%20(arm_tidy%2C%203%2F4) PR: ClickHouse#126134
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
FunctionsStress.stressreports how long a stuck worker has been in its iteration and prints the stack trace of the first stuck worker.Description
Between 2026-10-15 10:00 and 20:25 UTC,
Unit tests (asan_ubsan, function_prop_fuzzer)failed with1 threads got stuckin 9 of 332 runs (7 PRs and 2 master runs), against 0 of 1,798 runs in the three days before; the MSan and TSan lanes had no such failure. Every report namesrange, for example PR #121704 and master 8f4f38d7:Thread is stuck while re-resolving and re-executing: SELECT range(materialize(CAST(9234215 AS Int32)));. That query takes under a second on its own, and the log carries nothing else, so the stall cannot be located from CI.On stuck detection the main thread now sends
STACK_TRACE_SERVICE_SIGNALto the first stuck worker while holding its mutex, so the worker cannot leave the reported step. A handler installed by the test copiesStackTrace(ucontext)for that thread only; the main thread waits up to 10 s and prints one line per frame: the offset inunit_tests_dbms(forllvm-symbolizer --obj), or in the named shared library, and the demangled name. It only reads the symbol index, which is built at test start, so a stuck thread holding symbolization locks cannot block the report. It is skipped wherehasAsyncSignalSafeUnwind()is false (TSan). Each stuck line also gets the iteration age.Validation (ASan+UBSan): with a temporary infinite loop in
identity, the report showsThread is stuck for 35.0s while executing: ...and a stack whose top offset symbolizes to the loop line; a sleeping loop showsclock_nanosleep; without this change the same run prints only the query. Full 600-s runs with the CI options pass. In one of 26 such runs arange(CAST(1532863 AS UInt32))iteration took 116 s, so the slowrangecase does reproduce locally, but too rarely to bisect; this PR does not fix it.Workflow [PR]
Sync PR [sync-upstream/pr/126137]
Version info
26.11.1.24-master(included in26.11and later)