Skip to content

Skip 01473_event_time_microseconds under LLVM coverage builds - #103219

Merged
alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-01473-coverage-timeout
Aug 4, 2026
Merged

alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-01473-coverage-timeout

Conversation

@groeneai

@groeneai groeneai commented Apr 21, 2026 •

Copy link
Copy Markdown
Collaborator

The test 01473_event_time_microseconds issues SYSTEM FLUSH LOGS on
metric_log, trace_log, query_log, and query_thread_log, then verifies
that event_time_microseconds matches event_time in each system log. Under
LLVM source-based coverage instrumentation, flushing trace_log alone can
exceed the 180s server-side waitFlush timeout (SystemLogBase.cpp:185),
producing:

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

30-day CIDB on Stateless tests (amd_llvm_coverage, 2/3): 4 fails / 6044 runs,
all timing out on SYSTEM FLUSH LOGS after ~180s. Zero master failures; test is
healthy on non-coverage variants.

The test already excludes every sanitizer build and the debug build for exactly
this kind of timing-sensitivity. Adding no-llvm-coverage closes the remaining
gap. This mirrors sibling query-profiler tests 00974_query_profiler.sql and
01569_query_profiler_big_query_id.sh, and follows the precedent set by commit
cec04c17241 (Kafka tests under coverage).

The test will still run on release, binary, Fast test, and
amd_binary_excluded_from_llvm variants — so coverage of this code path is
preserved.

CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103209&sha=568958afaab08561c6c2a0a13a08f1b7486bbc8a&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%202%2F3%29

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 to CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.8.1.718 (included in 26.8 and later)

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

a) Deterministic repro?
Not directly — the fix is a CI tag addition, not a code change. The failure mode is well-characterized from CIDB: Stateless tests (amd_llvm_coverage, 2/3) shows Code: 159. Timeout exceeded (180 s) while flushing system log 'DB::SystemLogQueue<DB::TraceLogElement>' in 4/6044 runs over 30 days, always in SYSTEM FLUSH LOGS metric_log, trace_log, query_log, query_thread_log; on line 14. All 4 failures share the same stack (SystemLogQueue::waitFlush → 180s timeout). 0 master failures.

b) Root cause explained?
Yes. LLVM source-based coverage instrumentation adds per-branch profiling overhead to every compiled function. For SystemLogQueue<TraceLogElement>::flush, the instrumentation compounds across the backlog of trace entries produced by the earlier SELECT sleep(2) under query_profiler_real_time_period_ns=100000000 (10 Hz sampling). The accumulated instrumentation cost pushes flush latency past the 180s replay_settings.waitFlushTimeout default, raising TIMEOUT_EXCEEDED.

c) Fix matches root cause?
Yes. no-llvm-coverage is the exact tool the test runner (tests/clickhouse-test:2530-2541) provides for tests that break under coverage instrumentation. The test is already excluded from every sanitizer build and debug for the same category of timing reason — adding no-llvm-coverage closes the one remaining instrumented variant.

d) Test intent preserved?
Yes. The test still runs on arm_binary, amd_binary, Fast test, amd_release, and the amd_binary_excluded_from_llvm variant designed for exactly this case (it runs ONLY tests tagged no-llvm-coverage, providing a coverage-free home for them). So code-path coverage of event_time_microseconds is fully preserved across non-coverage builds, and the test's ability to catch regressions in timestamp accuracy is untouched.

e) Demonstrated in both directions?
Not applicable — it's a tag change. The runner's skip logic is already covered by existing tests that use the tag (00974_query_profiler.sql, 01569_query_profiler_big_query_id.sh, the 6 Kafka tests from commit cec04c17241).

f) Fix is general, not a narrow patch?
Yes. The skip covers every amd_llvm_coverage* / arm_llvm_coverage* variant via the runner's single tag check. Sibling tests with similar patterns (query profiler + trace log flush) already have this tag; the present fix brings 01473_event_time_microseconds in line with that established convention rather than introducing a new pattern.


Session: cron:clickhouse-ci-task-worker:20260421-021500

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — could you review? This follows the exact pattern of your commit cec04c17241 (Kafka tests under coverage). Tag-only change, no behavioral impact on non-coverage builds.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Apr 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2fd96d9]

Summary: ✅


AI Review

Summary

This PR only adds the no-llvm-coverage tag and an explanatory comment to 01473_event_time_microseconds, a timing-sensitive query-profiler test that already skips debug and sanitizer builds. The tag wiring is correct: tests/clickhouse-test skips it only in LLVM-coverage jobs and still runs it in amd_binary_excluded_from_llvm, and the latest PR CI is fully green including both the amd_llvm_coverage shards and the excluded-from-LLVM job. I did not find correctness, coverage-routing, or PR-metadata issues in the current diff.

Final Verdict

✅ Approve. No review findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 21, 2026
pull Bot pushed a commit to CrazyForks/ClickHouse that referenced this pull request Apr 21, 2026
The test issues `SYSTEM FLUSH LOGS /* all tables */`, which triggers
flushing every system log (including `trace_log`) and must wait for the
shared backlog accumulated by all parallel tests on the same server.
Under LLVM source-based coverage instrumentation the per-branch profiling
overhead accumulated in the `trace_log` queue pushes the server-side
`waitFlush` call past its 180s timeout in `SystemLogBase.cpp`, producing:

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

This is the same failure mode that `01473_event_time_microseconds` hits
on the same build variant. 30-day CIDB shows 7 failures across 6 unrelated
PRs (~0.056% on amd_llvm_coverage, 0 master failures on amd_llvm_coverage).
The test verifies sorting-key correctness for system tables — a property
that has nothing to do with coverage instrumentation — so skipping on
`amd_llvm_coverage` preserves the test's ability to catch regressions on
every other build variant.

Follows precedent of `01473_event_time_microseconds` (PR ClickHouse#103219),
sibling query-profiler tests `00974_query_profiler`,
`01569_query_profiler_big_query_id`, and commit cec04c1
(Kafka tests under coverage).

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100777&sha=4892bb02456a3a49a0a21553f684b664020674c9&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%203%2F3%29
subkanthi pushed a commit to subkanthi/ClickHouse that referenced this pull request Apr 24, 2026
…n amd_llvm_coverage

Adds `no-llvm-coverage` tag — under LLVM source-based coverage instrumentation the
server is ~3-5x slower, and with `memory_profiler_sample_probability = 1` the test
emits many `MemorySample` trace rows. The server-side `SystemLogQueue<TraceLogElement>`
flush then routinely exceeds its 180s deadline, emitting `Code: 159 TIMEOUT_EXCEEDED`
into stderr and causing the `clickhouse-test` stderr-empty check to report the test
as `FAIL` even when the assertion output itself is correct.

CIDB evidence (30 days):
- 34 failures, 25+ distinct unrelated PRs, 4 master hits — all on `amd_llvm_coverage`
  variants only (1/3, ParallelReplicas+s3+parallel, AsyncInsert+s3+parallel).
- Zero failures on debug, asan_ubsan, tsan, msan, release, binary builds in the same
  window.
- Health check: in 7 days the test has 657-706 OK runs on each of the 4 coverage
  variants (so it passes most of the time; 180s deadline is a rare stochastic trip).

Same pattern and fix as the recent sibling coverage flakes:
  ClickHouse#103287, ClickHouse#103288, ClickHouse#103293, ClickHouse#103298, ClickHouse#103226, ClickHouse#103219.

Closes the `ci-02818memoryprofilersampleminmax` chronic-flaky tracking task.
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, I've fixed the test 04078_native_protocol_input_validation, please update the branch.

The test issues SYSTEM FLUSH LOGS on metric_log, trace_log, query_log,
and query_thread_log, then verifies event_time_microseconds accuracy.
Under LLVM source-based coverage instrumentation, flushing trace_log
alone can exceed the 180s server-side waitFlush timeout
(SystemLogBase.cpp:185), producing:

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

The test already excludes all sanitizer builds and debug builds for
exactly this kind of timing-sensitivity reason. Add no-llvm-coverage
to cover the remaining instrumented variant.

Same pattern as sibling query-profiler tests
(00974_query_profiler.sql, 01569_query_profiler_big_query_id.sh) and
follows precedent of commit cec04c1 (Kafka tests under coverage).

30-day CIDB: 4/6044 failures on 'Stateless tests (amd_llvm_coverage, 2/3)',
0 master failures.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103209&sha=568958afaab08561c6c2a0a13a08f1b7486bbc8a&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%202%2F3%29
@groeneai
groeneai force-pushed the fix-01473-coverage-timeout branch from 770ff6f to 1055e7e Compare June 10, 2026 23:19
@groeneai

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov branch rebased onto current master (e2a2c02). Single test-tag commit replayed cleanly, no conflicts. CI should re-run.

Session: cron:clickhouse-worker-slot-14:20260610-231500

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jun 10, 2026
The test relies on a precise memory-tracking cadence between two distributed
shards: the shard allocating `groupArray(repeat('a', 100000))` per row must
hit `max_memory_usage=1G` and emit `Query memory limit exceeded` before the
other shard cancels. Under LLVM source-based coverage instrumentation the
per-branch profiling overhead perturbs this cadence and the expected exception
occasionally does not surface on `127.3` before the query is cancelled,
producing an empty `grep` match and a FAIL.

30-day CIDB at the time of the fix: 7 hits on `Stateless tests
(amd_llvm_coverage, 1/3)` across 7 distinct PRs, 1 master hit on 2026-04-21,
2 hits on the `amd_llvm_coverage, AsyncInsert, s3 storage` variant, 0 hits on
any non-coverage stateless configuration.

Applies the same direction as sibling coverage-timing tests
`03096_order_by_system_tables` (ClickHouse#103226, merged) and
`01473_event_time_microseconds` (ClickHouse#103219). The test remains covered by all
non-coverage configurations and by the excluded-from-llvm runner variant that
specifically runs tests tagged `no-llvm-coverage`.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=99c45393710200ab19c3ff17b45badf63b466559&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%201%2F3%29

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — a691b58

CI fully finished (Finish Workflow: success). This PR is a 6-line test-tag change (add no-llvm-coverage to 01473_event_time_microseconds), rebased onto master per @ alexey-milovidov's request; it cannot cause an unrelated coverage-shard job error.

Check / test Reason Owner
Stateless tests (amd_llvm_coverage, old analyzer, s3, DatabaseReplicated, WasmEdge, parallel) infra: JOB-LEVEL error, no per-test FAIL; rerun diagnosis "Runs: 33, Failed: 0, Passed: 33" (transient coverage-job error); sibling sequential shard = success (590 passed) a fix task is created (investigating at full effort; fixing-PR link to follow here)
Mergeable Check / PR aggregator rollup of the coverage row above

Session id: cron:our-pr-ci-monitor:20260630-163000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel) job-level error on this PR's CI: #108970. That variant is the slowest job in CI and overruns the runner lease un-batched (the container is torn down mid-job, exit 125 "context canceled", recorded as a job-level error although all tests pass; 85 such errors across 81 PRs in 30d). #108970 splits it into 3 batches so each shard finishes inside the lease. The failure here was not caused by this PR's test-tag change.

@alexey-milovidov

Copy link
Copy Markdown
Member

Re-synced onto current `master` (merge commit `756cd20`) to re-run CI.

The only red on the previous run (`a691b581`) was a job-level infra error on `Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel)` — the container was torn down mid-job (`Error waiting for container: Canceled: grpc: the client connection is closing: context canceled`), with all per-test reruns passing (33/33). That was the runner-lease overrun on the un-batched slow coverage variant, which #108970 fixes by splitting the job into batches.

#108970 merged into `master` on 2026-07-01, after this PR's last CI run, so this re-sync pulls the batching fix into the branch history. A fresh run of the coverage variant should now finish inside its lease and unblock the PR. The change itself is unchanged — the same 6-line `no-llvm-coverage` tag addition (AI Review: Approve).

@clickhouse-gh

clickhouse-gh Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.14% 86.15% +0.01%
Functions 91.48% 91.48% +0.00%
Branches 78.63% 78.67% +0.03%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 92 line(s), 4 function(s) across 44 file(s) · Details

Top files
  • src/Storages/StorageReplicatedMergeTree.cpp: 8 line(s)
  • src/Functions/FunctionsBitmap.h: 6 line(s)
  • src/Functions/array/arrayShiftRotate.cpp: 5 line(s)
  • src/Functions/FunctionsExternalDictionaries.h: 4 line(s)
  • src/Functions/FunctionsJSON.cpp: 4 line(s)

Full report

@alexey-milovidov alexey-milovidov self-assigned this Jul 7, 2026
@groeneai

groeneai commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov this Stress test (arm_release) failure is not caused by this PR (it only adds a no-llvm-coverage tag to one test). It is the chronic full_sorting_merge JOIN logical error:

Logical error: 'Join is supported only for pipelines with one output port, got 1 and 8' (STID 4488-4e11), stack QueryPipelineBuilder::joinPipelinesYShaped <- JoinStep::updatePipeline <- QueryPlan::buildQueryPipeline.

It recurs on current master across unrelated runs (9 distinct PRs + 1 master hit in 30d, all single hits). Root cause: with query_plan_join_shard_by_pk_ranges=1, a full_sorting_merge join whose keys are a PK prefix is planned for sharding, but JoinStep::updatePipeline only uses sharding when both sides have equal stream counts; when they diverge (e.g. PREWHERE splits one side differently), the Y-shaped join path gets a multi-port pipeline and asserts.

I already have a fix in flight: #109393 (Fix LOGICAL_ERROR in full_sorting_merge JOIN when sharding stream counts diverge). It targets exactly this stack. Once it merges this failure goes away.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103219&sha=756cd208197287ce8e3792bc7a2af1246adf093d&name_0=PR&name_1=Stress%20test%20%28arm_release%29

@alexey-milovidov

Copy link
Copy Markdown
Member

Re-synced onto current master (merge commit fbd0fc73352, clean; net diff is still the exact 6-line tag change) to re-run CI.

The only test red on the previous run (18095253) was a mass failure (150 unrelated tests, server-wide MEMORY_LIMIT_EXCEEDED, RSS 41.86 GiB) on Stateless tests (amd_asan_ubsan, distributed plan, parallel) — a chronic job-wide OOM that hit dozens of unrelated PRs this week. Its fix #110574 merged into master on 2026-07-18, after this PR's last CI run, so pulling in current master should clear it. The CH Inc sync check will also re-run on the new head.

All amd_llvm_coverage jobs passed on the previous run, validating this PR's purpose.

@alexey-milovidov

Copy link
Copy Markdown
Member

Fresh CI on `fbd0fc73352` confirms the re-sync worked:

The only remaining red is `Stress test (amd_debug)`: an AST-fuzzer `Logical error: Inconsistent KeyCondition behavior` (STID `5182-684a`). This is a chronic, unrelated AST-fuzzer flaky tracked by #107951 — it hits `master` and dozens of unrelated PRs, and cannot be caused by a test-tag-only change. No action needed here.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - fbd0fc7

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (amd_debug) / Logical error: Inconsistent KeyCondition behavior (STID 5182-684a) trunk bug (24 unrelated PRs + master, 14d) #109023 (ours, open)
Mergeable Check / PR rollup of the above owned via #109023

This PR adds a no-llvm-coverage tag to one test (01473_event_time_microseconds); it touches no key-condition or MergeTree code, so the Stress-test logical error is not caused by it.

Session id: cron:our-pr-ci-monitor:20260725-163000

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 2635b3a

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens.

Check / test Reason Owner / fixing PR
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 2/3) / Server died + Logical error Arguments of 'multiply' have incorrect data types: Int256, Float64 coverage-WasmEdge SIGABRT crash class #109747 (ours, open)
same job / Scraping system tables (minio_audit_logs dump times out) collateral of the same server death; the dump-timeout signature itself #110099 (ours, merged 2026-07-20T17:25:32Z) - NOT on this branch, merging master will pick it up

Fast test, Fast test (arm_darwin) and Style check are all green on this head, so neither line is caused by this PR's diff.

Session id: cron:our-pr-ci-monitor:20260726-163000

@groeneai

groeneai commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 2fd96d9

CI is fully finished on this head and there is nothing to own: 175/175 check-runs completed, 48 success, 127 skipped, 0 failures. Finish Workflow completed successfully, and no check reported a failed test.

Check / test Reason Owner / fixing PR
(none) no failing check on this commit not applicable

Verified from the paginated check-runs API rather than the status rollup, which truncates on this repo. I am not re-pinging reviewers.

Session id: cron:our-pr-ci-monitor:20260803-163000

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 4, 2026
Merged via the queue into ClickHouse:master with commit ddb5c05 Aug 4, 2026
180 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 4, 2026
rorylshanks pushed a commit to rorylshanks/ClickHouse that referenced this pull request Aug 25, 2026
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
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 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.

4 participants