Skip to content

Disable flaky 02434_cancel_insert_when_client_dies under LLVM coverage - #108864

Closed
groeneai wants to merge 2 commits into
ClickHouse:masterfrom
groeneai:ci-02434-no-llvm-coverage
Closed

groeneai wants to merge 2 commits into
ClickHouse:masterfrom
groeneai:ci-02434-no-llvm-coverage

Conversation

@groeneai

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

Disable 02434_cancel_insert_when_client_dies under LLVM coverage (no-llvm-coverage tag).

No related open issue found (historical #67599 is closed).

Failure: recurring red check on master, Stateless tests (amd_llvm_coverage_per_test, per_test_coverage, 6/8) — 7 hits in the last 30 days, exactly one per weekly NightlyCoverage run (06-01, 06-04, 06-08, 06-11, 06-15, 06-21, 06-27), and zero failures on any non-coverage build. Reason: result differs with reference.

Root cause (not a result/count divergence): the diff in every failure shows all three expected values present and correct — the only divergence is LLVM Profile Error: lines injected between them:

@@ -1,3 +1,9 @@
 500000
+LLVM Profile Error: Invalid profile data to merge
+LLVM Profile Error: Profile Merging of file clickhouse-client-proc0-...profraw failed: Success
+LLVM Profile Error: Failed to write file "clickhouse-client-proc0-...profraw": Success
 500000
 1

thread_cancel SIGINT/SIGKILLs clickhouse-client processes mid-insert (the whole point of the test). Under LLVM coverage instrumentation each client writes to a shared profraw merge pool on exit; killing one mid-write corrupts the pool, and surviving instrumented clients then print LLVM Profile Error: to stderr. insert_data folds client stderr into stdout via 2>&1, so those lines land in the captured .stdout diffed against .reference. The runner already strips LLVM Profile Error: from its own stderr capture (#97020) but not from the test's merged stdout.

Fix: add no-llvm-coverage. Coverage data collected from a process killed mid-merge is invalid by construction, so the test should not run under coverage — the same rationale as the existing no-asan/no-msan/no-tsan/no-debug exclusions. The test runs unchanged on every other build, fully preserving its ability to verify cancellation.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=b3461b9116ed78b84a6c37fa846134523a46e21f&name_0=NightlyCoverage&name_1=Stateless%20tests%20%28amd_llvm_coverage_per_test%2C%20per_test_coverage%2C%206%2F8%29

The test SIGKILLs clickhouse-client processes mid-insert (thread_cancel).
Under LLVM coverage instrumentation each client writes to a shared profraw
merge pool on exit; killing one mid-write corrupts the pool, and surviving
instrumented clients then print "LLVM Profile Error:" lines to stderr.

insert_data folds client stderr into stdout via 2>&1, so those error lines
land in the captured .stdout that is diffed against .reference, producing a
false "result differs with reference". The three expected values
(500000/500000/1) are always present and correct - only the LLVM runtime
noise diverges. The runner already strips these lines from its own stderr
capture (PR ClickHouse#97020) but not from the test's merged stdout.

This recurs once per weekly NightlyCoverage run (7 master hits in 30 days,
all on amd_llvm_coverage_per_test, zero on any other build). Coverage data
collected from a process that is killed mid-merge is invalid by definition,
so the test should not run there - same rationale as the existing
no-asan/no-msan/no-tsan/no-debug exclusions.

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

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The CI signature is deterministic across all 7 weekly hits. The underlying runtime mechanism was reproduced deterministically with a minimal instrumented binary: a clean run creates a shared %m profraw pool; corrupting that pool (as a SIGKILL'd mid-merge process leaves it) makes a surviving instrumented process print LLVM Profile Error: Profile Merging of file ...profraw failed / Failed to write file ...profraw to stderr, while its real stdout stays correct.
b Root cause explained? thread_cancel SIGINT/SIGKILLs clickhouse-client mid-insert. Under LLVM coverage each client writes a shared profraw merge pool on exit; a kill mid-write corrupts the pool, so surviving instrumented clients emit LLVM Profile Error: to stderr. insert_data ... 2>&1 (line 56) folds that stderr into the captured .stdout diffed against .reference -> false "result differs". The 500000/500000/1 values are always present and correct.
c Fix matches root cause? Yes. The failure is a fundamental coverage incompatibility (a kill-race cannot produce valid coverage), so skipping under coverage with no-llvm-coverage removes the cause, mirroring the existing no-asan/no-msan/no-tsan/no-debug exclusions. Not a band-aid: nothing in the test logic or assertions is weakened.
d Test intent preserved / new tests added? Preserved. On every non-coverage build the test runs unchanged and still verifies that repeated insert cancellation keeps the table at 500000 rows and that cancellation actually fired. Only the coverage build (where the test is structurally invalid) is skipped.
e Both directions demonstrated? Yes, validated against the runner's own tag parser + skip condition (tests/clickhouse-test): with the tag, llvm_coverage=True -> SKIPPED (false failure eliminated); llvm_coverage=False -> RUNS (intent preserved). Mechanism repro shows errors-with-instrumentation vs clean-output-without.
f Fix is general across code paths? N/A (flaky test tag fix, not a code bug). Sibling tests 02434_cancel_insert_when_client_dies_* are separate and not affected by this signature.
g Fix generalizes across inputs? N/A (flaky test tag fix, not a code bug).
h Backward compatible? N/A (flaky test tag fix, not a code bug).
i Invariants and contracts preserved? N/A (flaky test tag fix, not a code bug).

Session id: cron:clickhouse-worker-slot-0:20260629-215600

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @CheSema — could you review this one-line test tag change? Adds no-llvm-coverage to 02434_cancel_insert_when_client_dies: under coverage, thread_cancel killing instrumented clients mid-write corrupts the shared profraw merge pool, so survivors print LLVM Profile Error: lines that 2>&1 folds into the diffed stdout (false "result differs"). 7 master hits in 30d, all on amd_llvm_coverage_per_test, zero elsewhere — same rationale as the existing no-asan/no-msan/no-tsan/no-debug tags.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 29, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [74dc65c]

Summary: ✅


AI Review

Summary

This PR adds no-llvm-coverage to 02434_cancel_insert_when_client_dies.sh to suppress false LLVM Profile Error: diffs in coverage builds. The rationale is sound for that test, but the fix is incomplete: the distributed sibling still uses the same clickhouse-client + SIGKILL + merged-stderr pattern, so the same coverage-only false failure can still surface there.

Findings

⚠️ Majors

  • [tests/queries/0_stateless/02434_cancel_insert_when_client_dies.sh:4] The PR's contract is to exclude this kill-and-retry pattern from llvm_coverage because killing instrumented clickhouse-client corrupts the shared profraw merge pool and later leaks LLVM Profile Error: into the compared output. tests/queries/0_stateless/04365_cancel_insert_when_client_dies_distributed.sh still has the same ingredients: insert_data only invokes CLICKHOUSE_CLIENT, thread_cancel still randomly sends SIGKILL, and thread_insert still does 2>&1 | grep -Fav "Killed" at line 45. That leaves the same false-red mechanism reachable under llvm_coverage; it can just move from 02434 to 04365.
    Suggested fix: add the same no-llvm-coverage tag and rationale to tests/queries/0_stateless/04365_cancel_insert_when_client_dies_distributed.sh, or provide evidence that the distributed sibling cannot emit the same runtime noise.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions:

  • Extend the no-llvm-coverage exclusion to tests/queries/0_stateless/04365_cancel_insert_when_client_dies_distributed.sh, or show why its all-clickhouse-client cancellation loop is immune to the same LLVM Profile Error: failure mode.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 29, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.60% 85.62% +0.01%
Functions 91.46% 91.46% +0.00%
Branches 78.24% 78.28% +0.04%

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

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

Top files
  • src/Disks/IO/CachedOnDiskWriteBufferFromFile.cpp: 15 line(s)
  • src/Functions/FunctionsBitmap.h: 6 line(s)
  • src/Functions/LeftRight.h: 5 line(s)
  • src/AggregateFunctions/TimeSeries/AggregateFunctionTimeSeriesGroupArray.h: 4 line(s)
  • src/Functions/h3ToString.cpp: 4 line(s)

Full report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 7a3ac9d

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_tsan / arm_tsan / arm_asan_ubsan) / Hung check failed, possible deadlock found chronic shutdown-deadlock (not PR-caused: this PR only adds a no-llvm-coverage tag to one stateless .sh test, which cannot cause a stress hung-check) #101680 / #105905 (ours, open)
CH Inc sync — CH Inc sync (private, not actionable)

Mergeable Check / PR are the aggregator jobs reflecting the three chronic Stress hung-check reds above; no separate owner.

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

# Tags: no-random-settings, no-asan, no-msan, no-tsan, no-async-insert, no-debug, no-fasttest, no-replicated-database
# Tags: no-random-settings, no-asan, no-msan, no-tsan, no-async-insert, no-debug, no-fasttest, no-replicated-database, no-llvm-coverage
# no-fasttest: The test runs for 40 seconds
# no-llvm-coverage: thread_cancel SIGKILLs instrumented clients mid-write, corrupting the shared

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.

Why is the distributed sibling left under llvm_coverage? The rationale in this comment still applies to tests/queries/0_stateless/04365_cancel_insert_when_client_dies_distributed.sh: its insert_data path uses only CLICKHOUSE_CLIENT (tests/queries/0_stateless/04365_cancel_insert_when_client_dies_distributed.sh:25-30), thread_cancel still randomly sends SIGKILL, and thread_insert still folds stderr into the compared output with 2>&1 | grep -Fav "Killed" (tests/queries/0_stateless/04365_cancel_insert_when_client_dies_distributed.sh:45). That means a killed client can still corrupt the shared profraw merge pool and a later client can still leak LLVM Profile Error: into the golden output, so this PR can just move the recurring coverage-only red from 02434 to 04365. Please either tag that sibling no-llvm-coverage too or explain what makes it immune.

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.

You are right that 04365 is not immune, and the verification made me conclude this PR is the wrong fix for the problem, so I am closing it in favour of #110716.

04365 on master has no no-llvm-coverage tag (line 2), inserts through the native $CLICKHOUSE_CLIENT (line 29), still does kill -s "$SIGNAL" with KILL (line 71), and still merges client stderr into the compared output at line 45. CIDB confirms it empirically rather than only structurally: 18 master failures in the last 45 days, all 18 carrying LLVM Profile Error: in the diff. Your prediction that tagging only 02434 moves the recurring red to 04365 is already observed reality.

Where I disagree is the remedy, and it applies to this PR too. The tag skips the test, but the test is not failing. In the last master failure (sha a8c156e623333d40936998a3b0d273966835912c, 2026-07-27 03:59) the captured stdout contains all three expected values, 500000 / 500000 / 1, present and correct; the only divergence is injected profiler lines. The cancellation path works fine under coverage, so skipping it discards a passing test.

clickhouse-test already treats this class as noise to filter rather than a reason to skip: lines 3135-3145 strip LLVM Profile Error: from stderr, with a comment citing #97020 and stating the test output is correct. These tests fail only because thread_insert folds client stderr into stdout with 2>&1 before the runner's filter can see it. The corrupted pool also belongs to clickhouse-client-* processes, whereas per-test coverage of the server is collected server side into system.coverage_log (lines 5704-5723) and survives a killed client, so the tag would trade real server coverage of the cancellation and deduplication path for suppressing a client-side output artifact.

#110716 applies that filter to all four carriers, 02434, 02435, 04365 and 04366, and leaves every one of them running under coverage. Its 04365 hunk is what you are asking for here, by the mechanism the runner already uses. I verified it by extracting each revision's committed filter chain and running it against the real captured stdout above: master differs from the reference, the #110716 chain matches it byte for byte, a genuine Code: 341. DB::Exception still survives the filter, and removing just the new filter breaks it again.

@groeneai groeneai closed this Jul 29, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Closing this in favour of #110716, which fixes the same failure by a better mechanism.

The recurring red here is not a test-logic failure. In the last master occurrence (sha a8c156e623333d40936998a3b0d273966835912c, 2026-07-27 03:59, per_test_coverage 6/8) the captured stdout holds all three expected values, 500000 / 500000 / 1, present and correct, and the only divergence is LLVM Profile Error: lines that coverage-instrumented clients print after thread_cancel kills one of them mid-write. thread_insert merges client stderr into the compared output with 2>&1, so the noise reaches the reference diff even though clickhouse-test already filters exactly these lines out of stderr (lines 3135-3145, citing #97020).

So the right fix is to filter the noise and keep running the test, not to tag the test out of coverage. Skipping it also loses real coverage: the corrupted profraw files belong to clickhouse-client-* processes, while per-test coverage of the server is collected server side into system.coverage_log (lines 5704-5723) and is unaffected by a killed client.

#110716 adds that one filter to all four affected tests, 02434, 02435, 04365 and 04366, so it also covers the 04365 gap the automated review raised on this PR. Nothing from this PR is left unaddressed, so there is no reason to keep two competing changes to the same file open.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants