Repository navigation
Do not symbolize trace_log in-flush on coverage builds either - #119187
alexey-milovidov merged 2 commits into
Conversation
Stateless jobs on amd_llvm_coverage lose whole runs to `Timeout exceeded (180 s) while flushing system log 'DB::SystemLogQueue<DB::TraceLogElement>'`. Six different tests died on this signature inside a single coverage job run on 2026-09-05, so it is a job-wide trace_log drain stall rather than a property of any one test. trace_log.symbolize defaults to true, and in-flush symbolization (SymbolIndex::findSymbol + tryDemangle + AddressToLineCache::get, per frame in TraceLogElement::appendToBlock) is what the single flusher thread spends the hardcoded 180 s of SystemLogQueue::waitFlush on. ClickHouse#100242 already fixed that by shipping tests/config/config.d/trace_log_no_symbolize.xml, but its gate probes CXX_FLAGS LIKE '%-DSANITIZER%' and the else arm removes the file again. A coverage build is configured -DSANITIZE= ... -DWITH_COVERAGE=ON, so it carries no -DSANITIZER: coverage was the one stateless flavour left symbolizing at full cost. Probe the dedicated WITH_COVERAGE row of system.build_options instead. Plain -DWITH_COVERAGE never reaches CXX_FLAGS (cmake/sanitize.cmake adds it only under WITH_COVERAGE_DEPTH; the coverage compile flags are applied per-directory), which is why build_option_flag cannot be reused and why tests/clickhouse-test keys off the same row. The new helper keeps the fail-closed contract of its neighbour: a renamed or missing row aborts the install rather than reading as "not a coverage build", and every probe is resolved before any file is touched, so a failing probe cannot leave a half-adjusted config directory. Measured on a debug build, a fresh server per arm (AddressToLineCache is a process-wide static, so a warmed process understates the cost) and an identical workload, timing the first SYSTEM FLUSH LOGS trace_log: 0.35 s with symbolize=false, 0 of 13226 rows symbolized, versus 3.12 s with symbolize=true, 13388 of 13388 symbolized. That is 8.9x, i.e. symbolization is ~89% of flush cost; ClickHouse#100242 measured up to 2.5 minutes for ~180k entries on an instrumented build. This removes the dominant per-row cost without making the 180 s budget unconditional, and deliberately does not touch that constant: raising it is the shape ClickHouse#105484 was closed for. The tests that assert a non-empty symbols or lines column (03150_trace_log_add_build_id, 03150_trace_log_source_lines) already carry no-llvm-coverage, and 00974_query_profiler resolves symbols on read, so nothing regresses; the comments naming the affected flavours are updated to match. One consumer did not resolve on read: the MemoryAllocatedWithoutCheck advisory in tests/clickhouse-test suggests a diagnostic query grouped by the symbols column. Those rows reach trace_log through MemoryTracker -> TraceSender -> TraceCollector, which stamps every row with the config's symbolize value, so the suggested query has collapsed every stack into a single empty bucket on all sanitizer builds since 2026-05-08. It now resolves symbols on read with addressToSymbol, which repairs the guidance for both flavours. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review of
Severity: ❌ blocker / The end-to-end signal is this PR's own Session id: cron:clickhouse-review-slot-10:20260910-095800 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20260910-054700 |
|
Workflow [PR], commit [b3b0b5d] Summary: ✅ AI ReviewSummaryThis PR extends Findings
Final Verdict
LLVM Coverage ReportMeasured on commit b3b0b5d.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +374 lines in 104 files (-141 lines lost coverage) · Details |
|
cc @alexey-milovidov, could you review this? |
…GE row install_build_type_configs runs on every install.sh invocation, including `install.sh --previous-release` from tests/docker_scripts/stress_tests.lib. The upgrade check reaches it after the previous release's packages are already installed (upgrade_runner.sh installs them at line 91 and configures at line 131), so the binary answering the probe there is the released one, not the build under test. system.build_options gained its WITH_COVERAGE row in 26.2, added by e536581 ("Fix detecting coverage build") as a single line; 26.1 and 25.12 have no such row. On those the probe returns 'missing' and, under `set -x -e`, aborts the install before the previous-release server can start. Measured on the official builds: 26.1.13.3 reports 0 WITH_COVERAGE rows of 70 build_options rows and the probe exits 1, while 26.8.3.77 reports 1 of 76 and the probe answers 0. Gate it the way the rest of the file gates version-dependent decisions, on check_clickhouse_version, and read an older server as not a coverage build: an official release never is one. The fail-closed contract is unchanged for every build that can carry the row, a renamed row still aborting on 26.8.3.77. This abort was not reachable on master: the upgrade check selects the newest release older than the package under test, which is v26.8.2.7-lts today (read from the previous_release_tag line of a 2026-09-10 job log) and only moves forward. The gate keeps it out of reach for an older previous release. Co-Authored-By: Claude Opus 5 <[email protected]>
| fi | ||
|
|
||
| if [ "$is_sanitizer" = "1" ]; then | ||
| if [ "$is_sanitizer" = "1" ] || [ "$is_coverage" = "1" ]; then |
There was a problem hiding this comment.
Extending trace_log_no_symbolize.xml to coverage builds makes system.trace_log.symbols empty on the regular amd_llvm_coverage shards too, but the use-xray tests tests/queries/0_stateless/03642_system_instrument_entry_exit.sh:34 and tests/queries/0_stateless/03642_system_instrument_profile.sh:32-45 still assert on arrayExists(..., symbols). clickhouse-test only skips use-xray when use_xray is absent, and the regular coverage build does not turn ENABLE_XRAY off, so those tests still run there. That means this change swaps the current flush timeout for deterministic false negatives in the instrumentation test family. Please either resolve those checks on read from trace (addressToSymbol with allow_introspection_functions = 1) or tag the affected tests no-llvm-coverage.
There was a problem hiding this comment.
Not changing this one: the premise does not hold. Instrumentation rows are symbolized regardless of the trace_log config, so both tests are unaffected by the config this PR installs.
InstrumentationManager::createTraceLogElement sets element.symbolize = true unconditionally (src/Interpreters/InstrumentationManager.cpp:479), and TraceLogElement::appendToBlock gates the symbols/lines columns on that per-element flag (src/Interpreters/TraceLog.cpp:263), not on the log-level setting. The setting only reaches profiler rows, which TraceCollector builds with .symbolize = symbolize (src/Interpreters/TraceCollector.cpp:221). TraceLog.cpp:111 states the same thing in the column description.
Measured rather than argued. Local debug tree, USE_XRAY=1, so clickhouse-test does not skip use-xray (tests/clickhouse-test:3265-3267). One fresh server per arm, the arms differing only in whether tests/config/config.d/trace_log_no_symbolize.xml sits in config.d, then both tests through the runner:
| arm | 03642_..._entry_exit + ..._profile |
Instrumentation rows / symbolized | profiler rows / symbolized |
|---|---|---|---|
| file installed (what this PR does on coverage) | 2/2 pass | 81 / 81 | 1656 / 0 |
| file absent (coverage today) | 2/2 pass | 81 / 81 | 1616 / 1616 |
The profiler column is the activation check: 0 symbolized proves the config took effect in the first arm, so the passing tests are not the file being silently ignored. The tests' own predicate holds in both arms too, 27 of 27 rows with function_name LIKE '%QueryMetricLog::startQuery%' matching arrayExists(x -> x LIKE '%dispatchHandler%', symbols).
Your second premise is correct and I checked it separately: the family does run on amd_llvm_coverage (about 58k OK rows per test over 45 days in the CI database), and it is skipped on every sanitizer shard because CMakeLists.txt:112 turns XRay off when SANITIZE is set. So the sanitizer flavour, where this config has been installed since #100242, gives no evidence either way, which is why I ran the arms above.
One addition to your enumeration: 03642_system_instrument_stress.sh:60 also filters on symbols, implicitly Instrumentation-only through function_name, and it already carries no-llvm-coverage. Those three are the complete set of use-xray tests that read system.trace_log.symbols.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Stateless jobs on
amd_llvm_coveragekeep losing whole runs toTimeout exceeded (180 s) while flushing system log 'DB::SystemLogQueue<DB::TraceLogElement>'. Sixdifferent tests died on this signature in
one coverage job run
on 2026-09-05, so it is a job-wide
trace_logdrain stall, not a property of any test.Root cause.
trace_log.symbolizedefaults totrue, and in-flush symbolization(
SymbolIndex::findSymbol+tryDemangle+AddressToLineCache::get, per frame, inTraceLogElement::appendToBlock) is what the flusher spends its 180 s on. #100242 already fixedthis with
tests/config/config.d/trace_log_no_symbolize.xml, but its gate probesCXX_FLAGS LIKE '%-DSANITIZER%'and theelsearm removes the file. A coverage build isconfigured
-DSANITIZE= ... -DWITH_COVERAGE=ON, so it carries no-DSANITIZER: coverage was theone stateless flavour where the mitigation got deleted again.
Change. Probe
WITH_COVERAGE's dedicatedsystem.build_optionsrow and install the config forcoverage as well as sanitizer builds.
-DWITH_COVERAGEnever reachesCXX_FLAGS(added only underWITH_COVERAGE_DEPTH), so the existingCXX_FLAGShelper cannot answer this. The new helper isfail-closed: a renamed or missing row aborts the install rather than reading as "not coverage", and is
version-gated on 26.2, where that row landed, because the upgrade check configures a previous-release
server.
The
MemoryAllocatedWithoutCheckadvisory intests/clickhouse-testgrouped by thesymbolscolumn, which this config leaves empty; it now resolves symbols on read.
Validation. Debug build, fresh server per arm, identical workload, first flush timed: 0.35 s with
symbolize=false(0 of 13,226 rows symbolized) vs 3.12 s withsymbolize=true(13,388 of 13,388) -8.9x, so symbolization is ~89% of flush cost. No test is weakened and the 180 s constant is untouched
(#105484).
Residual in the same job, not addressed here: praktika wrote no results TSV after
clickhouse-testexited 1, so CIDB holds a job-level error with zero test rows for that head.Workflow [PR]
Sync PR [sync-upstream/pr/119187]
Version info
26.9.1.1260(included in26.9and later)