Skip to content

Skip 01514_distributed_cancel_query_on_error under LLVM coverage builds - #103288

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-01514-distributed-cancel-llvm-coverage
Jul 29, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-01514-distributed-cancel-llvm-coverage

Conversation

@groeneai

@groeneai groeneai commented Apr 21, 2026 •

Copy link
Copy Markdown
Collaborator

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 amd_llvm_coverage 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.

Reproducibility check from the runner: Failed 0/3 reruns - intermittent, timing-dependent.

30-day CIDB

  • Stateless tests (amd_llvm_coverage, 1/3) - 7 hits across 7 distinct PRs, including 1 master hit on 2026-04-21
  • Stateless tests (amd_llvm_coverage, AsyncInsert, s3 storage, parallel) - 2 hits on 2 distinct PRs
  • Non-coverage stateless configurations - 0 hits
  • Fast test - 3 hits on 2 PRs, but those PRs modify unrelated code (PR author responsibility)

Same pattern as merged / open sibling fixes

The test remains covered by every non-coverage configuration and by the excluded-from-llvm runner variant that specifically runs tests tagged no-llvm-coverage, so the code path (max_memory_usage exception propagation across distributed shards) keeps its 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

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):

N/A - test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

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

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (session cron:clickhouse-ci-task-worker:20260421-184500)

# Answer
a) Deterministic repro? Not at single-query level — this is a timing race between two distributed shards. CIDB gives us the reproduction signal though: 7/7 cross-PR hits are on amd_llvm_coverage variants, 0/N hits on any non-coverage stateless configuration. That is a deterministic environmental repro — the failure mode is exclusive to source-based coverage instrumentation.
b) Root cause explained? LLVM source-based coverage inserts per-branch profiling calls into the server-side query pipeline. That slows memory-tracking updates enough that the shard allocating groupArray(repeat('a', 100000)) per row may NOT hit max_memory_usage=1G and emit Query memory limit exceeded before the other shard receives the cancellation signal. The expected exception text from 127.3 therefore never makes it into the client's stderr, the grep -F -q finds nothing, and the test FAILs. The same class of problem — coverage perturbing time-sensitive cancellation/flush/profiler behaviour — hits 01473, 03096, 03258, 04078, 03549, 02818.
c) Fix matches root cause? Yes. The fix is to stop running the test under amd_llvm_coverage (via the no-llvm-coverage tag) while keeping it in every other CI configuration plus the dedicated excluded-from-llvm variant which runs exactly the skipped-under-coverage set. That addresses the mechanism (coverage-induced timing skew) without weakening the test elsewhere.
d) Test intent preserved? Yes. The test asserts that the EARLIER shard's Query memory limit exceeded propagates to the client before 127.2 is hit. That assertion is still exercised by every non-coverage stateless configuration (debug, asan_ubsan, tsan, msan, binary, arm_binary, arm_asan_ubsan, AsyncInsert on non-coverage, s3 on non-coverage, …) and by the excluded-from-llvm runner. We are not lowering limits, shrinking data, or relaxing the grep.
e) Demonstrated in both directions? Ran locally on the Debug build: with --llvm-coverage flag the test is now correctly SKIPPED (Reason: test is not supported with llvm coverage enabled); without the flag it proceeds through the normal run. The current master behaviour under coverage was the FAIL 0/3 rerun pattern visible in CIDB, which is exactly what the tag now prevents.

Sibling PR #103226 (03096_order_by_system_tables) was approved and merged with the identical approach; this PR follows the same direction.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — could you review? Same coverage-timing pattern and same no-llvm-coverage fix as the sibling PR #103226 you approved earlier today.

@clickhouse-gh

clickhouse-gh Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [69da2f9]

Summary: ✅


AI Review

Summary

This PR adds the no-llvm-coverage tag to 01514_distributed_cancel_query_on_error.sh and documents why LLVM source-based coverage perturbs the timing the test depends on. I did not find a new correctness issue in the current diff: the PR workflow still includes Stateless tests (amd_binary_excluded_from_llvm), and the functional-test driver enables --shard by default there, so this distributed test remains exercised outside the coverage-instrumented lane rather than being dropped from CI entirely.

Final Verdict

✅ No review findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 22, 2026
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.
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
groeneai force-pushed the fix-01514-distributed-cancel-llvm-coverage branch from 8964c3d to dd4c6b1 Compare June 10, 2026 23:24
@groeneai

Copy link
Copy Markdown
Collaborator Author

Rebased onto current master and force-pushed to refresh CI. The previously red Fast test (2026-04-22) failed only on unrelated tests (01683_dist_INSERT_block_structure_mismatch, 01080_join_get_null, 01659_array_aggregation_ubsan, 01720_country_perimeter_and_area, 02423_insert_stats_behaviour), none of which this diff touches; it was stale CI on a 1.5-month-old base. The change remains a single tag-only edit adding no-llvm-coverage to the test, matching merged sibling #103226.

Session: cron:clickhouse-worker-slot-6:20260610-231759

@clickhouse-gh

clickhouse-gh Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.60% 84.70% +0.10%
Functions 92.30% 92.30% +0.00%
Branches 77.20% 77.30% +0.10%

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

Newly covered by added/modified tests: 345 line(s), 18 function(s) across 131 file(s) · Details

Top files
  • src/Storages/MaterializedView/RefreshTask.cpp: 13 line(s)
  • src/Storages/StorageReplicatedMergeTree.cpp: 13 line(s)
  • src/AggregateFunctions/TimeSeries/AggregateFunctionTimeSeriesGroupArray.h: 10 line(s), 8 function(s)
  • src/Common/ShellCommand.cpp: 9 line(s)
  • src/Functions/multiIf.cpp: 9 line(s)

Full report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finished on dd4c6b13de77. This is a test-tag-only change (adds no-llvm-coverage to 01514_distributed_cancel_query_on_error.sh); all build and functional checks pass or skip. The single red is not caused by this PR:

  • Stateless tests (arm_asan_ubsan, azure, sequential) — Server died / Segmentation fault (STID 0883-1653) / 00991_system_parts_race_condition_long: the Azure arm_asan_ubsan ASan-allocator-OOM mass outage of 2026-06-10/11 (20+ unrelated PRs, no ClickHouse frames). Orthogonal to a stateless test tag change.

CH Inc sync red is the internal mirror sync, expected on fork PRs. Ready for review.

@alexey-milovidov alexey-milovidov self-assigned this Jul 29, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 29, 2026
Merged via the queue into ClickHouse:master with commit 048229c Jul 29, 2026
179 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 Jul 29, 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 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