Skip to content

Fix flaky test 03258_nonexistent_db on LLVM coverage builds - #103287

Merged
evillique merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-03258-nonexistent-db-coverage-timeout
Apr 23, 2026
Merged

evillique merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-03258-nonexistent-db-coverage-timeout

Conversation

@groeneai

@groeneai groeneai commented Apr 21, 2026 •

Copy link
Copy Markdown
Collaborator

03258_nonexistent_db.sh wraps clickhouse-client --database nonexistent in timeout 5 and greps for UNKNOWN_DATABASE. On amd_llvm_coverage builds under parallel test load the coverage-instrumented client can take longer than 5 s to start and emit the error, the timeout kills it first, grep finds nothing and the test prints FAIL.

2026-04-21 13:16:08 @@ -1,2 +1 @@
2026-04-21 13:16:08 -UNKNOWN_DATABASE
2026-04-21 13:16:08 -OK
2026-04-21 13:16:08 +FAIL
2026-04-21 13:16:08 + [13:16:03] timeout 5 clickhouse-client --database nonexistent
2026-04-21 13:16:08 + [13:16:03] grep -o UNKNOWN_DATABASE
2026-04-21 13:16:08 + [13:16:08] echo FAIL

The timeout is only a safety net against a genuinely stuck client; the happy path completes in milliseconds. Raising it to 60 s accommodates LLVM coverage overhead while still catching a real hang, and preserves coverage of this client code path (no new no-* tag).

30-day CIDB: all 19 failures are amd_llvm_coverage* variants, including 3 master hits on 2026-04-21. 0 failures on regular builds.

This is the same symptom and fix direction as 04078_native_protocol_input_validation in #103210, which raised a 5 s socket timeout to 60 s for the same reason.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=1b90aee2d24bd44c14d55c9b27d06012177a1bb6&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.5.1.36

The test wraps `clickhouse-client --database nonexistent` in `timeout 5`
and greps for `UNKNOWN_DATABASE`. On `amd_llvm_coverage` builds under
parallel test load the coverage-instrumented client can take longer
than 5 s to start and emit the error, causing the grep to find nothing
and the test to print `FAIL`.

30-day CIDB: all 19 failures are `amd_llvm_coverage` variants; 0 on
regular builds. Same timing pattern as 04078_native_protocol_input_validation
(PR ClickHouse#103210), where the fix was to raise a 5 s socket timeout to 60 s.

Raising `timeout 5` to `timeout 60` keeps the test fast on happy paths
(runs in milliseconds normally) while giving enough headroom for slow
CI startup, and still catches a genuinely hung client.

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

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? CIDB shows 19 failures in 30 days — 100% on amd_llvm_coverage*, 0 on regular builds. 3 master hits today (2026-04-21). The environmental trigger is deterministic. Cannot reproduce locally without an amd_llvm_coverage binary + parallel test load.
b Root cause explained? LLVM source-based coverage instrumentation + parallel test load makes clickhouse-client startup occasionally exceed 5 s. timeout 5 kills the client before it emits UNKNOWN_DATABASE; the trailing grep -o finds nothing, the test echoes FAIL. Debug log from a failing run confirms this sequence: [13:16:03] timeout 5 clickhouse-client --database nonexistent → [13:16:08] echo FAIL.
c Fix matches root cause? Yes. Raising timeout 5 → timeout 60 directly addresses the slow-startup path. It is not an assertion weakening — the reference output is unchanged. The timeout is a safety net against a hung client, not a behavior check.
d Test intent preserved? Yes. The test still verifies clickhouse-client emits UNKNOWN_DATABASE on a nonexistent database. A client that genuinely hangs will still fail the test within 60 s.
e Both directions demonstrated? CIDB shows failure without the fix (19 coverage-build failures in 30 d). With the fix locally: 20/20 runs pass (expected — the happy path takes ms, timeout delta is irrelevant when the client responds fast).
f Fix is general, not a narrow patch? Test-only change; no code modification. Same direction as the 04078_native_protocol_input_validation fix in #103210 (raised 5 s socket timeout to 60 s for the identical root cause). No symmetric code sites to patch.

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

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — same pattern and fix direction as merged #103226 and open #103210 (LLVM-coverage timing). Could you review?

@clickhouse-gh

clickhouse-gh Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [25f3c49]

Summary: ✅


AI Review

Summary

This PR updates tests/queries/0_stateless/03258_nonexistent_db.sh to increase the safety timeout from 5 to 60 seconds for amd_llvm_coverage environments, with explanatory comments. The change is narrowly scoped, aligns with the stated flaky-test symptom, and does not introduce correctness, safety, or compatibility risks.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ➖
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict

Status: ✅ Approve

@evillique
evillique added this pull request to the merge queue Apr 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 23, 2026
@evillique
evillique added this pull request to the merge queue Apr 23, 2026
Merged via the queue into ClickHouse:master with commit b9b05d6 Apr 23, 2026
161 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 Apr 23, 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.
@groeneai groeneai mentioned this pull request Apr 29, 2026
1 task done
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