Skip to content

Fix flaky 03636_benchmark_error_messages under LLVM coverage - #103668

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-03636-no-llvm-coverage
Apr 29, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-03636-no-llvm-coverage

Conversation

@groeneai

@groeneai groeneai commented Apr 28, 2026 •

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Test 03636_benchmark_error_messages is flaky under amd_llvm_coverage builds.

Root cause

The test pipes clickhouse-benchmark stderr through grep -v filters that strip the EXPECTED error texts (Unrecognized option '--bad-option', Bad arguments: the argument ('bad value') for option '--timelimit' is invalid, invalid user: Authentication failed, Positional option 'pos_arg' is not supported.). Anything else that lands on stdout fails the test via the "exception in stdout" detector in clickhouse-test.

Under amd_llvm_coverage builds the server is ~3-5x slower, and under parallel test load the clickhouse-benchmark connection / handshake path hits the internal 10 s budget set by DBMS_DEFAULT_CONNECT_TIMEOUT_SEC (src/Core/Defines.h) and handshake_timeout_ms = 10000 (src/Core/Settings.cpp). When that timeout expires Connection::connect (src/Client/Connection.cpp:248) rethrows a Poco::TimeoutException wrapped as NETWORK_ERROR / SOCKET_TIMEOUT:

Code: 209. DB::NetException: Timeout exceeded while reading from socket
(peer: [::1]:9000, ..., 10000 ms): (localhost:9000, ::1,
local address: [::1]:NNNNN). (SOCKET_TIMEOUT)

That text is not in the grep -v filter list, so it leaks into stdout and fails the test.

Evidence

CIDB footprint (last 30 days): 16 failures across 13 distinct PRs, 4 master hits — 100 % on amd_llvm_coverage, 0 on any non-coverage build:

check_name hits
Stateless tests (amd_llvm_coverage, 2/3) 10
Stateless tests (amd_llvm_coverage, AsyncInsert, s3 storage, parallel) 3
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) 2
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel) 1

Every CI report shows Failed 0 out of 3 reruns, confirming the flake is timing-related, not a logic bug. Every failing log shows the exception with , 10000 ms) — the exact connect_timeout / handshake_timeout ceiling.

Fix

Apply no-llvm-coverage — the established pattern for the same class of flake. The same fix was applied to the closely-related 02550_benchmark_connections_credentials in PR #103298 with identical root-cause analysis, and to other timing-sensitive flakes on the same variant: 01473_event_time_microseconds, 03096_order_by_system_tables, 03258_nonexistent_db, 04078_native_protocol_input_validation, 01514_distributed_cancel_query_on_error, 02293_http_header_full_summary_without_progress.

The test continues to run on every other build (debug, ASan + UBSan, TSan, MSan, release, binary), so its clickhouse-benchmark argument-validation coverage is preserved. A deeper fix would require bumping connect_timeout / handshake_timeout for this test specifically, but that is outside the scope of a CI-stability fix and would complicate the test's semantics.

Local verification on debug build (amd_debug): 50/50 passes with full settings randomization enabled.

Example failing report (master): https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=e964f640e43bd3a1c582d0f610de73085e0ecf40&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%202%2F3%29

CI session: cron:clickhouse-ci-task-worker:20260428-094500

Version info

  • Merged into: 26.5.1.162

The test pipes `clickhouse-benchmark` stderr through `grep -v` filters that
strip the EXPECTED error texts (`Unrecognized option '--bad-option'`,
`Bad arguments: the argument ('bad value') for option '--timelimit' is
invalid`, `invalid user: Authentication failed`, `Positional option
'pos_arg' is not supported.`). Anything else that lands on stdout fails
the test via the "exception in stdout" detector in `clickhouse-test`.

Under `amd_llvm_coverage` builds the server is ~3-5x slower, and under
parallel test load the `clickhouse-benchmark` connection / handshake path
hits the internal 10 s budget set by `DBMS_DEFAULT_CONNECT_TIMEOUT_SEC`
(`src/Core/Defines.h`) and `handshake_timeout_ms = 10000`
(`src/Core/Settings.cpp`). When that timeout expires
`Connection::connect` rethrows a `Poco::TimeoutException` wrapped as
`NETWORK_ERROR` / `SOCKET_TIMEOUT`:

    Code: 209. DB::NetException: Timeout exceeded while reading from
    socket (peer: [::1]:9000, ..., 10000 ms): (localhost:9000, ::1,
    local address: [::1]:NNNNN). (SOCKET_TIMEOUT)

That text is not in the `grep -v` filter list, so it leaks into stdout
and fails the test.

CIDB footprint (last 30 days): 16 failures across 13 distinct PRs, 4
master hits. 100% on `amd_llvm_coverage` variants
(`2/3`, `AsyncInsert, s3 storage, parallel`,
`ParallelReplicas, s3 storage, parallel`, and
`old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel`),
0 on any non-coverage build. Every CI report shows
`Failed 0 out of 3 reruns`, confirming the flake is timing-related.

Apply `no-llvm-coverage`, the established pattern for the same class of
flake, also used by `02550_benchmark_connections_credentials` (PR
ClickHouse#103298), `01473_event_time_microseconds`, `03096_order_by_system_tables`,
`03258_nonexistent_db`, `04078_native_protocol_input_validation`,
`01514_distributed_cancel_query_on_error`, and
`02293_http_header_full_summary_without_progress`. The test continues to
run on every other build (debug, ASan + UBSan, TSan, MSan, release,
binary), so its `clickhouse-benchmark` argument-validation coverage is
preserved.

Example failing report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=e964f640e43bd3a1c582d0f610de73085e0ecf40&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%202%2F3%29
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (per worker policy):

a) Deterministic repro under CI conditions. 16/16 CIDB failures in the last 30 days carry the exact , 10000 ms) socket timeout — matches DBMS_DEFAULT_CONNECT_TIMEOUT_SEC / handshake_timeout_ms precisely. 100% on amd_llvm_coverage variants, 0% elsewhere.

b) Root cause explained. Under LLVM source-based coverage the server is ~3-5× slower; under parallel test load the clickhouse-benchmark connect/handshake path exceeds the 10 s internal budget; Poco::TimeoutException is re-thrown as NETWORK_ERROR / SOCKET_TIMEOUT; that text is not in the test's grep -v filter list (which only strips the four expected error messages), so it leaks into stdout and trips the "exception in stdout" detector.

c) Fix matches root cause. no-llvm-coverage skips the test on the only environment where the failure occurs. Same approach as PR #103298 (02550_benchmark_connections_credentials) and the other no-llvm-coverage precedents listed in the description.

d) Test intent preserved. The test still runs on debug, ASan + UBSan, TSan, MSan, release, and binary builds. It's an argument-validation test for clickhouse-benchmark; coverage instrumentation adds no unique signal here that the other variants don't already exercise.

e) Both directions demonstrated.

  • "Passes on non-coverage build" — verified locally: 50/50 OK on debug amd_debug with full setting randomization.
  • "Fails on coverage build without fix" — verified via 16 CIDB failures across 13 unrelated PRs, all with the 10 000 ms timeout fingerprint.
  • "Passes on coverage build with fix" — by construction: the runner skips the test on coverage when the tag is present (tests/clickhouse-test:2535-2540).

f) Fix is general, not narrow. N/A — test-only flake fix, not a code bug fix.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @azat — could you review this? Same root cause and fix pattern as PR #103298 (which you reviewed): clickhouse-benchmark's internal 10 s connect/handshake timeout fires under amd_llvm_coverage parallel load, and the resulting SOCKET_TIMEOUT text isn't in the test's grep -v filter, so it leaks into stdout and trips the exception detector. CIDB shows 16/16 last-30-day failures all on amd_llvm_coverage, all with the exact , 10000 ms) fingerprint.

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

clickhouse-gh Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [adad3b8]

Summary: ✅


AI Review

Summary

This PR adds a no-llvm-coverage tag to 03636_benchmark_error_messages.sh and documents why the test is flaky specifically under LLVM coverage due to timeout-induced SOCKET_TIMEOUT noise in stderr filtering. The change is narrowly scoped and appropriate for a CI-stability fix.

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

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 28, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

@alexey-milovidov alexey-milovidov self-assigned this Apr 29, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Apr 29, 2026
Merged via the queue into ClickHouse:master with commit f124dc7 Apr 29, 2026
165 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 29, 2026
pull Bot pushed a commit to Lobinson1/ClickHouse that referenced this pull request Jul 22, 2026
clickhouse-benchmark uses the default handshake_timeout_ms=10000 (10s) and
connect_timeout=10s. On slow lanes (amd_tsan, s3 storage, parallel) the TLS
handshake to the secure port can take longer than 10s under load, so the client
aborts with Code: 209 DB::NetException Timeout exceeded (SOCKET_TIMEOUT) before
certificate verification runs. That breaks both checks: the first invocation
loses its expected "certificate verify failed" line, and the SOCKET_TIMEOUT text
trips grep Exception in the second invocation. "Server died" is the harness
verdict from the same slow-response window, not a crash.

Add --connect_timeout 60 --handshake_timeout_ms 60000 to the benchmark
invocations so the handshake has a generous budget on slow lanes. The test still
verifies the same behavior: --secure without --accept-invalid-certificate still
prints "certificate verify failed", and --secure --accept-invalid-certificate
still succeeds with no exception.

Same approach as 01600_benchmark_query (ClickHouse#108570) and 03636_benchmark_error_messages
(ClickHouse#103298, ClickHouse#103668).

Reported on ClickHouse#100332 by alexey-milovidov.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
clickhouse-benchmark uses the default handshake_timeout_ms=10000 (10s) and
connect_timeout=10s. On slow lanes (amd_tsan, s3 storage, parallel) the TLS
handshake to the secure port can take longer than 10s under load, so the client
aborts with Code: 209 DB::NetException Timeout exceeded (SOCKET_TIMEOUT) before
certificate verification runs. That breaks both checks: the first invocation
loses its expected "certificate verify failed" line, and the SOCKET_TIMEOUT text
trips grep Exception in the second invocation. "Server died" is the harness
verdict from the same slow-response window, not a crash.

Add --connect_timeout 60 --handshake_timeout_ms 60000 to the benchmark
invocations so the handshake has a generous budget on slow lanes. The test still
verifies the same behavior: --secure without --accept-invalid-certificate still
prints "certificate verify failed", and --secure --accept-invalid-certificate
still succeeds with no exception.

Same approach as 01600_benchmark_query (ClickHouse#108570) and 03636_benchmark_error_messages
(ClickHouse#103298, ClickHouse#103668).

Reported on ClickHouse#100332 by alexey-milovidov.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.

3 participants