Repository navigation
Fix flaky 02550_benchmark_connections_credentials under LLVM coverage - #103298
Conversation
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
How so? There is no time limit for running binaries |
|
@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
Under LLVM coverage the server runs ~3–5× slower, and with The timings in the failing reports line up exactly with this:
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. PR description updated. Happy to revise further if you'd prefer a different approach (e.g. explicit |
You are welcome. I can do it all day long
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 |
|
Workflow [PR], commit [178e627] Summary: ✅ AI ReviewSummaryThis PR updates ClickHouse Rules
Final Verdict
|
…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 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
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]>
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]>
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]>
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]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...
Documentation entry for user-facing changes
Test
02550_benchmark_connections_credentialsis flaky underamd_llvm_coveragebuilds.Root cause (revised after @azat's feedback)
The test pipes
clickhouse-benchmark -i 1stderr togrep -F -oand 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-benchmarkhas 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/receiveHellopath can exceed this 10 s budget. When either timeout expires,Connection::connect(src/Client/Connection.cpp:248) rethrows aPoco::TimeoutException(wrapped asNETWORK_ERROR/SOCKET_TIMEOUT). That exception's text is something likeTimeout: connect timed out: 127.0.0.1:9000— it does not containAuthentication failed, because authentication never got a chance to run.grep -F -otherefore has nothing to match and emits no line. The reference diff shows exactly this — the authentication-specific line is absent but the surroundingecho user/echo passwordlabels are intact.Evidence
Across the 5 most recent failures (past 7 days), each failing
clickhouse-benchmarkinvocation took 10–11 seconds, matching the timeout ceiling exactly; every passing invocation took < 10 s:MySQL: Authentication failedMySQL: Authentication failedMySQL: Authentication failedMySQL: Authentication failedFailure 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_timeoutfiring.CIDB footprint (30 days): 16 failures, 13 distinct PRs, 100 % on
amd_llvm_coverage, 0 on any non-coverage build:Stateless tests (amd_llvm_coverage, 3/3)Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)Stateless tests (amd_llvm_coverage, AsyncInsert, s3 storage, parallel)Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel)Every CI report shows
Failed 0 out of 3 reruns, confirming the flake is timing-related, not a logic bug.Fix
Apply
no-llvm-coverageto 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_timeoutfor this test explicitly — seeSETTINGSor--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
26.5.1.42