Skip to content

Do not symbolize trace_log in-flush on coverage builds either - #119187

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-trace-log-symbolize-coverage-builds
Sep 12, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-trace-log-symbolize-coverage-builds

Conversation

@groeneai

@groeneai groeneai commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Stateless jobs on amd_llvm_coverage keep losing whole runs to
Timeout exceeded (180 s) while flushing system log 'DB::SystemLogQueue<DB::TraceLogElement>'. Six
different tests died on this signature in
one coverage job run
on 2026-09-05, so it is a job-wide trace_log drain stall, not a property of any test.

Root cause. trace_log.symbolize defaults to true, and in-flush symbolization
(SymbolIndex::findSymbol + tryDemangle + AddressToLineCache::get, per frame, in
TraceLogElement::appendToBlock) is what the flusher spends its 180 s on. #100242 already fixed
this with tests/config/config.d/trace_log_no_symbolize.xml, but its gate probes
CXX_FLAGS LIKE '%-DSANITIZER%' and the else arm removes the file. A coverage build is
configured -DSANITIZE= ... -DWITH_COVERAGE=ON, so it carries no -DSANITIZER: coverage was the
one stateless flavour where the mitigation got deleted again.

Change. Probe WITH_COVERAGE's dedicated system.build_options row and install the config for
coverage as well as sanitizer builds. -DWITH_COVERAGE never reaches CXX_FLAGS (added only under
WITH_COVERAGE_DEPTH), so the existing CXX_FLAGS helper cannot answer this. The new helper is
fail-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 MemoryAllocatedWithoutCheck advisory in tests/clickhouse-test grouped by the symbols
column, 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 with symbolize=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-test exited 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

  • Merged into: 26.9.1.1260 (included in 26.9 and later)

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]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Sep 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review of f2e59c1c77148: an independent cold read of the resulting code, then an
independent model pass (engine: codex; 2 findings), adjudicated together. 4 findings total, 0 blockers.

# Sev Finding Verdict Evidence / action
1 ⚠️ No live test or evidence proves the coverage probe installs and activates the symbolization override (tests/config/install.sh) DISAGREE Both halves are recorded. Installation: the real re-decide entry point (install.sh --build-type-configs-only, the one clickhouse_proc.py:345 uses) driven through a 6-row probe matrix, coverage=1 installing the config and 0 removing it, idempotent both ways, sanitizer arms unchanged, plus a no-shim negative arm on the real binary. Fail-closed and ordering: a missing row aborts rc=1 and leaves the tree byte-identical, so the abort precedes every file operation. Activation: 13,226 rows / 0 symbolized / 0.35 s versus 13,388 rows / 13,388 symbolized / 3.12 s on workloads matched within 1.2%. The one element not supplied is a compiled WITH_COVERAGE=ON binary, and that step carries no information: the value clickhouse local returns is the literal string configure_file substitutes into StorageSystemBuildOptions.cpp.in:74, and the generated .cpp from a real -DWITH_COVERAGE=ON configure was read directly (WITH_COVERAGE=ON, no -DSANITIZER in CXX_FLAGS). tests/clickhouse-test:5776-5783 already keys BuildFlags.WITH_COVERAGE off that same row in CI today. The premise about test liveness is right but is not a defect: the unit under change is a bash installer with no in-tree test harness, and #100242 shipped this config and gate the same way
2 💡 The PR body carried no visible provenance link for the failure being fixed AGREE, fixed in the body The only linked relationship sat in the template's HTML comment. The body now links the CI report for the coverage run in which six different tests died on this signature
3 💡 install.sh now answers "is this a coverage build?" twice, with two different failure contracts (is_fast_build declines when the row is absent, the new helper aborts) AGREE, noted, no change Deliberate. Routing is_fast_build through the fail-closed helper would turn an unrelated path's silent decline into an install abort, which is a behaviour change outside this PR
4 💡 The commit message omits the CI report URL and the corresponding PR URL DISAGREE The remedy asked for is a commit with no tree change, since amending the frozen commit is not available. The substance belongs in the PR body and is there now. Only 12 of the last 400 master commit bodies reference a test-report URL at all, and this message already carries the signature, the frame-level mechanism, #100242, #105484 and the measurement

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal
per finding.

The end-to-end signal is this PR's own amd_llvm_coverage stateless jobs: I will check from a
coverage job's artifacts that trace_log_no_symbolize.xml is in the installed config.d and that
05055_unknown_profile_event_in_trace_list passes there.

Session id: cron:clickhouse-review-slot-10:20260910-095800

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Sep 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, and it is a decision rather than a race: with the coverage probe answering 1 the config is installed, with 0 it is removed, reproduced on demand six times through BUILD_TYPE_CONFIGS_ONLY=1 ./tests/config/install.sh <cfg> <client> --build-type-configs-only. The cost mechanism reproduces deterministically too (0.35 s vs 3.12 s flush on matched workloads).
b Root cause explained? trace_log.symbolize defaults to true (SystemLog.cpp:287); the mitigation config from #100242 is gated on CXX_FLAGS LIKE '%-DSANITIZER%' and the else arm removes it; a coverage build is configured -DSANITIZE= ... -DWITH_COVERAGE=ON and carries no -DSANITIZER (verified on a real -DWITH_COVERAGE=ON configure), so the flusher symbolizes per frame in TraceLogElement::appendToBlock against the hardcoded 180 s in SystemLogBase.cpp:191.
c Fix matches root cause? Yes: it removes work from the flusher by extending the existing merged mitigation to the flavour its gate misses. Not a band-aid: timeout_seconds is untouched (a bump is the shape #105484 was closed for), and no test is tagged, skipped or weakened.
d Test intent preserved / new tests added? Preserved; no test's behaviour changes and there is no src/ change, so no regression test is owed. The two tests that assert non-empty symbols / lines (03150_trace_log_add_build_id, 03150_trace_log_source_lines) already carry no-llvm-coverage, so the guarantee they cover is untouched.
e Both directions demonstrated? Yes, twice. Config branch: coverage=1 installs the file, coverage=0 removes it, idempotent in both directions across six consecutive runs. Mechanism: symbolize=false flushes 13,226 rows in 0.35 s with 0 symbolized; symbolize=true flushes 13,388 rows in 3.12 s with 13,388 symbolized.
f Fix is general across code paths? Yes. It lives in install_build_type_configs, the single function called by both the full install (install.sh:312) and the binary-swap re-decide path (:163, used by clickhouse_proc.py:345) - which is why a job-name-derived --llvm-coverage flag was rejected. It fixes all eight tests observed on this signature, not one, and the one sibling consumer of the symbols column found by a full-tree grep is fixed in the same PR.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for datatypes (CI harness config, no expression path). The equivalent input space is the probe's answer set, and all three arms are exercised: ON/1 to 1, OFF to 0, row absent to a loud abort. upper() makes the comparison case-insensitive.
h Backward compatible? (maintainer-approved exception only) Yes, vacuously: test-harness config only. No SettingsChangesHistory.cpp, no server default, no format or version change. Non-coverage non-sanitizer installs are byte-identical, since the else arm already removed the file.
i Invariants and contracts preserved? Yes, and both are tested rather than asserted. Fail-closed probe contract: an unanswerable WITH_COVERAGE row aborts the install (cannot determine whether this is a coverage build ... output 'missing') instead of reading as false. Ordering: a run whose probe fails leaves an already-installed tree unchanged, so a failing probe cannot leave a half-adjusted config directory.

Session id: cron:clickhouse-impl-slot-40:20260910-054700

@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b3b0b5d]

Summary: ✅


AI Review

Summary

This PR extends trace_log_no_symbolize.xml to WITH_COVERAGE builds and updates one advisory query to resolve symbols on read. The added 26.2 version gate fixes the earlier previous-release installer regression, but the current head still leaves some use-xray coverage tests reading system.trace_log.symbols directly, so I cannot approve it yet.

Findings

⚠️ Majors

  • [tests/config/install.sh:156] Enabling trace_log_no_symbolize.xml for coverage builds makes system.trace_log.symbols empty on the regular amd_llvm_coverage shards too, but 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 keeps ENABLE_XRAY on, so these tests still run and will start failing for the same reason 00974_query_profiler.sql had to stop reading symbols. Suggested fix: resolve those assertions from trace on read (addressToSymbol with allow_introspection_functions = 1) or explicitly tag the affected tests no-llvm-coverage.
Final Verdict
  • Status: ⚠️ Request changes
  • Update the remaining use-xray tests that still depend on in-flush symbols population, or exclude them from LLVM coverage.

LLVM Coverage Report

Measured on commit b3b0b5d.

Metric Baseline Current Δ
Lines 88.90% 89.00% +0.10%
Functions 91.80% 91.80% +0.00%
Branches 81.30% 81.30% +0.00%

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

Full report

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 10, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov, could you review this? tests/config/install.sh gates trace_log_no_symbolize.xml on CXX_FLAGS LIKE '%-DSANITIZER%' and its else arm deletes the file again, so a coverage build (configured -DSANITIZE= ... -DWITH_COVERAGE=ON, hence no -DSANITIZER) is the one stateless flavour still symbolizing per frame inside the trace_log flush, which is how whole coverage jobs die on the hardcoded 180 s budget. This probes the dedicated WITH_COVERAGE row of system.build_options instead, in the same install_build_type_configs you merged in #118459.

Comment thread tests/config/install.sh Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 10, 2026
…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]>
Comment thread tests/config/install.sh
fi

if [ "$is_sanitizer" = "1" ]; then
if [ "$is_sanitizer" = "1" ] || [ "$is_coverage" = "1" ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@alexey-milovidov alexey-milovidov self-assigned this Sep 12, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 12, 2026
Merged via the queue into ClickHouse:master with commit fdb2319 Sep 12, 2026
174 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants