Skip to content

Mark 04411_memory_profiler_sample_probability as no-llvm-coverage - #116242

Merged
PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04411-no-llvm-coverage
Aug 25, 2026
Merged

PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-04411-no-llvm-coverage

Conversation

@groeneai

@groeneai groeneai commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #114204

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

04411_memory_profiler_sample_probability_sql_settings runs a query with
memory_profiler_sample_probability = 1, then SYSTEM FLUSH LOGS trace_log, then asserts
that a MemorySample row is visible. The flush deadline is a hardcoded
timeout_seconds = 180 in SystemLogQueue::waitFlush (src/Common/SystemLogBase.cpp:191),
and the index it waits for is a server-global queue position, so it drains the trace rows of
every concurrently running parallel test. Under LLVM coverage instrumentation the server is
slow enough to cross 180 s, and the flush throws:

Code: 159. DB::Exception: Timeout exceeded (180 s) while flushing system log
'DB::SystemLogQueue<DB::TraceLogElement>'. (TIMEOUT_EXCEEDED)
(in query: SYSTEM FLUSH LOGS trace_log)

That is not only stderr noise: the following SELECT count() > 0 ... 'MemorySample' then
prints 0, so the lane reports a false negative.

Over 30 days of coverage-lane runs that PASSED, this test has p50 9.8 s and p95 185.5 s
(max 202.3 s) against p50 5.1 s / p95 11.1 s in every other lane, and 2310 of 37668 are
already over 180 s. Two crossed it on the flush: amd_llvm_coverage, 3/3 on 2026-08-20
(report)
and amd_llvm_coverage, ParallelReplicas, s3 storage, parallel on 2026-07-23.

no-llvm-coverage is the standing remedy for this mechanism: 36 stateless tests carry it, and
this test's direct sibling 02818_memory_profiler_sample_min_max_allocation_size was tagged
for the same reason in 36decd61 ("Mark tests that timed out under LLVM coverage as
no-llvm-coverage"). 04411 was created two months later, which is why it was missed.

Coverage is relocated, not lost: the inverse filter in tests/clickhouse-test makes
Stateless tests (amd_binary_excluded_from_llvm) run exactly the tagged complement, where
02818 and 01473_event_time_microseconds pass ~4370 times per 14 days while 04411 is
currently skipped. The test keeps running unchanged in every non-coverage lane. One residual,
shared with all 36 tagged tests: the per-test coverage job also passes --llvm-coverage, so
this test's per-test attribution is dropped too.

Tag/flag matrix (local runner, Build-ID verified server)
tag runner flag result
present --llvm-coverage [ SKIPPED ] 0.00 sec
present --excluded-from-llvm [ OK ] 5.54 sec
removed --llvm-coverage [ OK ] 1.14 sec
removed --excluded-from-llvm [ SKIPPED ] 0.00 sec
present none [ OK ] 1.04 sec

With the tag removed both verdicts invert, so the probe measures the tag rather than an
unrelated skip reason.

Prior art on the identical intervention: #103219 tagged 01473_event_time_microseconds
(merged 2026-08-04); its coverage-lane failures over 120 days are 5 before that instant and
0 after. 02818 has none in the last 120 days either; its last ones are from the day it was
tagged.


Workflow [PR]
Sync PR [sync-upstream/pr/116242]

Version info

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

04411_memory_profiler_sample_probability_sql_settings runs a query with
memory_profiler_sample_probability = 1, then SYSTEM FLUSH LOGS trace_log,
then asserts a MemorySample row is visible.

SystemLogQueue::waitFlush uses a hardcoded timeout_seconds = 180
(src/Common/SystemLogBase.cpp:191) and waits for getLastLogIndex(), a
server-global queue position, so the flush drains the trace rows of every
concurrently running parallel test rather than only this test's. Under LLVM
source-based coverage instrumentation the server is slow enough that this
crosses 180 s, waitFlush throws at :213 with

  Code: 159. Timeout exceeded (180 s) while flushing system log
  'DB::SystemLogQueue<DB::TraceLogElement>'. (TIMEOUT_EXCEEDED)

and the following SELECT count() > 0 then reads 0, so the coverage lane
reports a false negative rather than only contaminating stderr.

Over 30 days of coverage-lane runs that PASSED, this test has p50 9.6 s and
p95 183.6 s (max 202.3 s) against p50 5.1 s / p95 11.1 s in every other lane,
and 2307 of 37648 coverage runs already exceed 180 s. Two crossed it on the
flush: Stateless tests (amd_llvm_coverage, 3/3) on 2026-08-20 (PR ClickHouse#115623)
and (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) on 2026-07-23
(PR ClickHouse#109174).

Report for the 2026-08-20 failure:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115623&sha=9b52646c82721f24b7dfb1ddc58d949beef5a7d0&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%203%2F3%29

no-llvm-coverage is the established remedy for this mechanism: 36 stateless
tests carry it, and commit 36decd6 ("Mark tests that timed out under LLVM
coverage as no-llvm-coverage") applied it to five tests including this test's
direct sibling 02818_memory_profiler_sample_min_max_allocation_size, whose
shape is identical. 04411 was created two months after that commit, which is
why it was missed.

Coverage is relocated, not lost: the inverse filter at
tests/clickhouse-test:2967-2971 makes Stateless tests
(amd_binary_excluded_from_llvm) run exactly the tagged complement, and the
two flags are mutually exclusive by construction
(ci/jobs/functional_tests.py:608-612). Over 14 days in that job the tagged
siblings 02818 and 01473_event_time_microseconds are OK 4367 and 4365 times
while 04411 is SKIPPED 4367 times. The same intervention on 01473 (ClickHouse#103219,
merged 2026-08-04) took its coverage-lane failures from 5 to 0.

Raising or parameterizing the 180 s constant was rejected: it is a
server-wide change for one test, the constant is already a deliberate
concession to parallel-test load, and because the drain is global a larger
value only moves the threshold.

Validated with the real runner. With the tag, --llvm-coverage skips and
--excluded-from-llvm runs; with the tag removed both verdicts invert, which
is the liveness proof that the arms measure the tag. Without any coverage
flag the test still runs, 10/10.

Related: ClickHouse#114204
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Aug 25, 2026
@groeneai

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

Two independent reviews of this change: a cold read of the resulting tree, and a separate
model pass against the frozen PR description. Six findings, all resolved before this PR
opened. No source finding: the diff is 4 added lines in one test file.

⚠️ A countable claim in an earlier draft of this description was wrong and was corrected.
The draft said 02818's lifetime coverage-lane failure count is 0. CIDB says 39 (2026-01: 5,
2026-03: 3, 2026-04: 31), 9 of them on the day it was tagged. The defensible statement, and
the one now in the description, is that 02818 has had none in the last 120 days.

# Finding Verdict
❌ Description asserted "02818's lifetime coverage-lane failure count is 0"; the true lifetime count is 39, with 0 in the last 120 days AGREE - description corrected to the 120-day claim
⚠️ Relationship line used #114204 instead of the full GitHub URL the PR template asks for AGREE - replaced with the full URL, then the description was re-reviewed so the reviewed text is what was published
⚠️ Undisclosed residual: the per-test coverage job also passes --llvm-coverage, so this test's per-test attribution is dropped, not only its aggregate lines AGREE - disclosed in the description; it is a property of the standing remedy shared by all 36 tagged tests
💡 ### Description was one word over the 300-word budget AGREE - condensed
💡 The commit message names literal classes, functions and SQL without inline code blocks, and writes getLastLogIndex with parentheses, against the in-tree AGENTS.md guidance DISAGREE (no action on this commit) - the only remedy is amending the message, which the same file's first line forbids. The source comment itself is compliant. Noted for the next commit rather than fixed by an amend
💡 Independent carrier enumeration (every stateless test combining memory_profiler_sample_probability with SYSTEM FLUSH LOGS trace_log) DROPPED - same 5 files, same disposition. The two untagged ones are non-carriers for reasons that corroborate the mechanism: 01092_memory_profiler is no-parallel, so nothing else is in the server-global drain, and 02497_trace_events_stress_long is long, which coverage lanes drop. Over 90 days in %llvm_coverage% neither has a single failure

The mechanism was re-verified at source rather than taken from the plan: the 180 s deadline
is hardcoded at src/Common/SystemLogBase.cpp:191 with no setting, the throw is at :213,
and the waited-for index comes from getLastLogIndex (:225-229) captured per log in
SystemLogs::flush (src/Interpreters/SystemLog.cpp:579-583), which is what makes the drain
server-global. The runner gate is two-sided by construction: tests/clickhouse-test:2958-2965
skips a tagged test under --llvm-coverage, :2967-2971 is the inverse filter, and the two
flags are mutually exclusive at ci/jobs/functional_tests.py:608-612.

Session id: cron:clickhouse-review-slot-49:20260825-032800

@clickhouse-gh clickhouse-gh Bot closed this Aug 25, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? YES for the change's own claim, which is a test-selection property: all 5 runner arms below are reproducible on demand. The 180 s flush timeout itself is load-dependent (2 failures against 37648 coverage runs in 30 d) and needs a coverage build plus ~9 concurrent workers, so I did not chase it locally. Instead the causal chain is pinned at source (SystemLogBase.cpp:191,204,213) plus the CI stack trace, and the distribution is measured: coverage-lane p95 183.6 s with 2307 of 37648 runs already past 180 s.
b Root cause explained? YES. SYSTEM FLUSH LOGS trace_log waits in SystemLogQueue::waitFlush on a HARDCODED timeout_seconds = 180 (src/Common/SystemLogBase.cpp:191) for a server-GLOBAL queue index, so it drains every concurrent parallel test's trace rows. Coverage instrumentation slows that drain past 180 s, :213 throws Code: 159, and the subsequent count() > 0 then reads 0.
c Fix matches root cause? YES. Not a band-aid: no bound widened, no dataset reduced, no defensive check. It is the repository's standing remedy for this exact mechanism, established by 36decd61 ("Mark tests that timed out under LLVM coverage as no-llvm-coverage"), whose own list includes this test's direct sibling 02818. Raising or parameterizing the 180 s constant was rejected: server-wide blast radius for one test, and the drain is global so a larger constant only moves the threshold.
d Test intent preserved / new tests added? YES. The test body is untouched: memory_profiler_sample_probability = 1 and the 64000 min-allocation threshold, which ARE the test's subject, are unchanged. It keeps running in every non-coverage lane and now also runs in amd_binary_excluded_from_llvm, where its tagged siblings pass ~4370 times per 14 days. No new test is added because the deliverable IS a test-selection change.
e Both directions demonstrated? YES, as a full 2x2 on the real runner. Tag present: --llvm-coverage -> SKIPPED, --excluded-from-llvm -> OK 5.54 s. Tag removed: --llvm-coverage -> OK 1.14 s, --excluded-from-llvm -> SKIPPED. Both verdicts invert, so the probe measures the tag and not something else. Plus a no-flags control: still OK, 10/10.
f Fix is general across code paths? YES. Enumerated every stateless test that both sets memory_profiler_sample_probability and runs FLUSH LOGS (5 files) plus the CIDB breadth query on the while flushing system log signature. The 4 real carriers (02818, 01473, 03096, 03150, 01526) already carry the tag. 01092_memory_profiler, 02497_trace_events_stress_long and 00974_query_profiler were measured as ingredient-without-mechanism (0 flush-timeout hits; durations nowhere near 180 s; the last one fails only in a non-coverage lane) and deliberately not widened.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A by construction: this is a runner test-selection tag, not a code path with inputs, so there are no type wrappers, boundary values or settings matrix. The tag's own input space is the two mutually-exclusive runner flags plus neither, and all three are covered by the arms in (e).
h Backward compatible? (maintainer-approved exception only) YES, trivially. No setting, no default change, no serialization format, no user-visible behaviour. No SettingsChangesHistory.cpp entry is required, stated affirmatively so it need not be asked.
i Invariants and contracts preserved? YES. No source change, so no function pre/postcondition, data-structure invariant, lock ordering or error path is touched. The invariant this RESTORES is the lane one: a test whose oracle depends on a 180 s flush completing must not run where the server cannot meet that deadline.

50/50 randomized runs: N/A and deliberately not run. The change adds no test and alters no
query, so there is nothing new to randomize, and the test already carries no-flaky-check.
Substituted: 10/10 passes with the tag under --excluded-from-llvm, and 10/10 in an ordinary
lane.

Session id: cron:clickhouse-impl-slot-40:20260825-024900

@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cdb8fb8]

Summary: ✅


AI Review

Summary

This PR adds the no-llvm-coverage tag and a short rationale to 04411_memory_profiler_sample_probability_sql_settings.sh so the test is routed out of the LLVM-coverage lane while still running in the excluded_from_llvm complement. After checking the current diff, neighboring trace_log-flush tests, the runner routing in tests/clickhouse-test and ci/jobs/functional_tests.py, and the prior PR discussion, I did not find a current correctness, safety, coverage-routing, or PR-metadata problem in this change.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexbakharew, could you review this? It adds no-llvm-coverage to one stateless test whose oracle depends on SYSTEM FLUSH LOGS trace_log finishing inside the hardcoded 180 s deadline in SystemLogQueue::waitFlush, which the coverage lane crosses (p95 185.5 s over 30 days), leaving the following count() > 0 reading 0.

@PedroTadim PedroTadim self-assigned this Aug 25, 2026
@PedroTadim
PedroTadim added this pull request to the merge queue Aug 25, 2026
Merged via the queue into ClickHouse:master with commit 690d110 Aug 25, 2026
357 of 358 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 25, 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 groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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