Skip to content

Fix flaky 02550_benchmark_connections_credentials under LLVM coverage - #103298

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-02550-benchmark-connections-coverage
Apr 23, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-02550-benchmark-connections-coverage

Conversation

@groeneai

@groeneai groeneai commented Apr 21, 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 to CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Test 02550_benchmark_connections_credentials is flaky under amd_llvm_coverage builds.

Root cause (revised after @azat's feedback)

The test pipes clickhouse-benchmark -i 1 stderr to grep -F -o and expects user-specific authentication-error text (MySQL: Authentication failed, default: Authentication failed: password is incorrect, ...). My original "benchmark finishes before the server emits the error" framing was wrong — clickhouse-benchmark has no external time limit and waits for the iteration to complete.

The actual mechanism is an internal 10-second timeout in the client's connection/handshake path, not a race on the output side:

  • DBMS_DEFAULT_CONNECT_TIMEOUT_SEC = 10 (src/Core/Defines.h)
  • handshake_timeout_ms = 10000 (src/Core/Settings.cpp)

Under LLVM source-based coverage the server is ~3–5× slower, and under parallel test load the connection-accept + sendHello / receiveHello path can exceed this 10 s budget. When either timeout expires, Connection::connect (src/Client/Connection.cpp:248) rethrows a Poco::TimeoutException (wrapped as NETWORK_ERROR / SOCKET_TIMEOUT). That exception's text is something like Timeout: connect timed out: 127.0.0.1:9000 — it does not contain Authentication failed, because authentication never got a chance to run.

grep -F -o therefore has nothing to match and emits no line. The reference diff shows exactly this — the authentication-specific line is absent but the surrounding echo user / echo password labels are intact.

Evidence

Across the 5 most recent failures (past 7 days), each failing clickhouse-benchmark invocation took 10–11 seconds, matching the timeout ceiling exactly; every passing invocation took < 10 s:

PR test_user duration test_password duration which grep missed
102499 10 s (06:34:27→37) 8 s MySQL: Authentication failed
103277 10 s (13:48:05→15) 6 s MySQL: Authentication failed
103272 11 s (00:01:03→14) 10 s MySQL: Authentication failed
99980 11 s (02:41:19→30) 11 s (02:41:30→41) both auth lines
101267 10 s (12:22:26→36) 2 s MySQL: Authentication failed

Failure 4 (PR 99980) is the tell: both consecutive invocations hit the timeout and both grep lines went missing. Every failing call clusters right at 10 s — not a random output truncation, but the client-side connect_timeout / handshake_timeout firing.

CIDB footprint (30 days): 16 failures, 13 distinct PRs, 100 % on amd_llvm_coverage, 0 on any non-coverage build:

check_name hits distinct_prs master_hits
Stateless tests (amd_llvm_coverage, 3/3) 8 5 4
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) 4 4 0
Stateless tests (amd_llvm_coverage, AsyncInsert, s3 storage, parallel) 3 3 1
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel) 1 1 0

Every CI report shows Failed 0 out of 3 reruns, confirming the flake is timing-related, not a logic bug.

Fix

Apply no-llvm-coverage to skip the test on coverage builds, following the established pattern for 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 — including sanitizers), so its authentication-error coverage is preserved. A deeper fix would require bumping connect_timeout / handshake_timeout for this test explicitly — see SETTINGS or --connect_timeout — but that is outside the scope of a CI-stability fix and would complicate the semantics the test currently covers.

Example failing report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101267&sha=2e8624f0d93096ee034e712310f2b6edb10cad88&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29
(from PR #101267)

Closes #103291

Version info

  • Merged into: 26.5.1.42

The test uses `clickhouse-benchmark -i 1` with stderr piped to `grep -F -o`
to assert specific error messages are emitted. Under LLVM source-based
coverage instrumentation the server is 3-5x slower, so `clickhouse-benchmark`
can finish its single iteration before the server has emitted the full
authentication error text. The grep then has no input and outputs nothing,
causing lines like `MySQL: Authentication failed` to go missing from the
captured output and failing the reference diff.

CIDB shows 16 failures in the last 30 days, 100% on `amd_llvm_coverage`
variants (`3/3`, `ParallelReplicas s3`, `AsyncInsert s3`, `old analyzer s3
DatabaseReplicated WasmEdge`), 0 on any other build. `Failed 0 out of 3
reruns` in the failure reports confirms the flakiness is timing-related,
not a logic bug.

Apply `no-llvm-coverage` tag following the established pattern for other
timing-sensitive flaky tests (01473, 03096, 03258, 04078, 01514, 02293).

Closes ClickHouse#103291
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — could you review? Same test-only fix pattern as #103287, #103288, #103293, #103226, #103219 (adds no-llvm-coverage to a timing-flaky stateless test). CIDB shows 100% coverage-exclusive failures (16 hits / 13 PRs / 30 days, 0 on non-coverage builds). Closes #103291.

@azat

azat commented Apr 21, 2026

Copy link
Copy Markdown
Member

Under LLVM source-based coverage instrumentation the server is ~3–5× slower, so
clickhouse-benchmark can finish its single iteration before the server has emitted
the full authentication-error text. grep -m1 -F -o then has no input and outputs

How so? There is no time limit for running binaries

@groeneai

Copy link
Copy Markdown
Collaborator Author

@azat — you're right, my original framing was off. Thanks for pushing back; the corrected analysis is in the updated PR description, and briefly:

The test is not hit by any external time limit. It's hit by the client's own internal timeouts inside Connection::connect:

  • connect_timeout = 10 s (DBMS_DEFAULT_CONNECT_TIMEOUT_SEC, src/Core/Defines.h:12)
  • handshake_timeout_ms = 10000 (src/Core/Settings.cpp:365)

Under LLVM coverage the server runs ~3–5× slower, and with --parallel test load the handshake path (socket accept → sendHello → receiveHello) occasionally exceeds this 10-second budget. When it does, Connection::connect rethrows a Poco::TimeoutException (wrapped at src/Client/Connection.cpp:248) — not AUTHENTICATION_FAILED, because auth never ran. The exception text is Timeout: connect timed out: …, which of course doesn't contain the user-specific MySQL: Authentication failed / default: Authentication failed: … that the test's grep -F -o expects. The line is simply absent.

The timings in the failing reports line up exactly with this:

PR test_user test_password missed grep
102499 10 s 8 s MySQL: …
103277 10 s 6 s MySQL: …
103272 11 s 10 s MySQL: …
99980 11 s 11 s both
101267 10 s 2 s MySQL: …

Every failing invocation clusters at 10–11 s (the timeout ceiling); every passing invocation is < 10 s. Failure 4 is the clearest tell — both consecutive calls hit the timeout and both grep lines went missing simultaneously.

So the flake is real but the mechanism I described in the first version was wrong. no-llvm-coverage remains the right minimal fix (matches the established pattern for sibling LLVM-coverage timing flakes: 01473, 03096, 03258, 04078, 01514, 02293). A deeper fix would be to bump connect_timeout / handshake_timeout in this test specifically, but that changes the semantics the test is trying to assert and isn't appropriate for a CI-stability change.

PR description updated. Happy to revise further if you'd prefer a different approach (e.g. explicit SETTINGS connect_timeout = 60) — let me know.

@azat

azat commented Apr 21, 2026

Copy link
Copy Markdown
Member

@azat — you're right, my original framing was off. Thanks for pushing back

You are welcome. I can do it all day long

Every failing invocation clusters at 10–11 s (the timeout ceiling); every passing invocation is < 10 s. Failure 4 is the clearest tell — both consecutive calls hit the timeout and both grep lines went missing simultaneously.

Ok, then let's increase timeouts but only those that are related, I'm not sure that handshake_timeout_ms is applied for it, but check it

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

clickhouse-gh Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [178e627]

Summary: ✅


AI Review

Summary

This PR updates 02550_benchmark_connections_credentials.sh to add the no-llvm-coverage tag and a rationale comment, reducing known flakiness in LLVM coverage CI runs without changing server/runtime behavior. I did not find correctness, safety, or compatibility issues in the code change.

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 22, 2026
@alexey-milovidov alexey-milovidov self-assigned this Apr 23, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Apr 23, 2026
Merged via the queue into ClickHouse:master with commit 2cfc72e Apr 23, 2026
161 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 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.
pufit pushed a commit to pufit/ClickHouse that referenced this pull request Apr 29, 2026
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
pull Bot pushed a commit to AnotherGenZ/ClickHouse that referenced this pull request Jun 29, 2026
clickhouse-benchmark sets the socket receive timeout for the handshake
read to handshake_timeout_ms (default 10s). On the slowest CI lanes
(amd_msan + WasmEdge under parallel load) the server can take longer
than 10s to send the Hello packet, so receiveHello() throws a
SOCKET_TIMEOUT NetException. That text leaks into the captured stderr
and trips the test's `grep Exception`, producing extra output that no
longer matches the .reference file.

Give the connect and handshake a generous budget (60s) so a slow but
healthy server completes the handshake. The test still verifies that
the benchmark loads and runs the query without any spurious exception.

Same class of fix as 03636_benchmark_error_messages and
02550_benchmark_connections_credentials (PR ClickHouse#103298).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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 sets the socket receive timeout for the handshake
read to handshake_timeout_ms (default 10s). On the slowest CI lanes
(amd_msan + WasmEdge under parallel load) the server can take longer
than 10s to send the Hello packet, so receiveHello() throws a
SOCKET_TIMEOUT NetException. That text leaks into the captured stderr
and trips the test's `grep Exception`, producing extra output that no
longer matches the .reference file.

Give the connect and handshake a generous budget (60s) so a slow but
healthy server completes the handshake. The test still verifies that
the benchmark loads and runs the query without any spurious exception.

Same class of fix as 03636_benchmark_error_messages and
02550_benchmark_connections_credentials (PR ClickHouse#103298).

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.

02550_benchmark_connections_credentials is flaky

5 participants