Skip to content

Fix flaky test 01600_benchmark_query - #108570

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-flaky-01600-benchmark-query-handshake-timeout
Jun 29, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-flaky-01600-benchmark-query-handshake-timeout

Conversation

@groeneai

Copy link
Copy Markdown
Collaborator

No related open issue found (failure is a transient flaky surfaced on a single PR run).

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

01600_benchmark_query runs clickhouse-benchmark --iterations 10 --query "SELECT 1", captures stderr, and asserts (via grep Exception / grep Loaded) that no exception was raised and the query loaded.

clickhouse-benchmark sets the socket receive timeout for the handshake read to handshake_timeout_ms (default 10s) in Connection::connect() before receiveHello(). On the slowest CI lane (Stateless tests (amd_msan, WasmEdge, parallel), MSAN shadow memory + WasmEdge interpreter, under parallel load) the server can take longer than 10s to send the Hello packet, so receiveHello() throws Code: 209. DB::NetException: Timeout exceeded while reading from socket (... 10000 ms): (SOCKET_TIMEOUT). That text leaks into the captured stderr and trips grep Exception, so stdout no longer matches the .reference file and the test FAILs.

Fix: give connect and handshake a generous budget (--connect_timeout 60 --handshake_timeout_ms 60000) so a slow but healthy server completes the handshake. The test still verifies 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 (#103298).

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]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Point clickhouse-benchmark at a TCP listener that accepts but never sends Hello: clickhouse benchmark --host ::1 --port <hang> --iterations 1 --query "SELECT 1" reproduces the exact error Code: 209. DB::NetException: Timeout exceeded while reading from socket (... 10000 ms): (SOCKET_TIMEOUT). The timeout value tracks handshake_timeout_ms (proved: --handshake_timeout_ms 2000 → "2000 ms" in 2.2s; default → "10000 ms" in 10.2s).
b Root cause explained? Connection::connect() sets the socket receive timeout to handshake_timeout_ms (default 10s) for the receiveHello() read. On the slow amd_msan+WasmEdge lane under parallel load the server needs >10s to send Hello → ReadBufferFromPocoSocket throws SOCKET_TIMEOUT "while reading from socket ... 10000 ms" → the text leaks into captured stderr → grep Exception matches → .reference mismatch → FAIL.
c Fix matches root cause? Yes. Raises the connect + handshake budget (--connect_timeout 60 --handshake_timeout_ms 60000) so a slow but healthy server has time to send Hello. Directly targets the 10s handshake timeout from (b), not a symptom.
d Test intent preserved / new tests added? Yes. The assertions (grep Exception finds none, grep Loaded = "Loaded 1 queries.") are unchanged. The test still verifies the benchmark loads + runs the query with no spurious exception. No source change → no new regression test needed.
e Both directions demonstrated? Yes. Fixed test 30/30 PASS against a healthy server. Window-moved proof: OLD 10s budget caps at 10.2s (the failing path); FIXED 60s budget waits past 10s until the server itself closes at 14s (a different, server-closed error), confirming the handshake budget moved from 10s.
f Fix is general across code paths? N/A (flaky test setting fix, not a code bug).
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (flaky test setting fix, not a code bug).
h Backward compatible? (maintainer-approved exception only) N/A (test-only change; no settings default, format, or validation change).
i Invariants and contracts preserved? N/A (test-only change; raises client-side timeout budget, no engine invariant touched).

Session id: cron:clickhouse-worker-slot-0:20260626-044400

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @azat — one-line test fix: raise clickhouse-benchmark connect/handshake timeout in 01600 so the default 10s handshake_timeout_ms does not leak a SOCKET_TIMEOUT into stderr on the slow amd_msan+WasmEdge lane (same class as #103298).

@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c45eed0]

Summary: ✅


AI Review

Summary

This PR raises the clickhouse-benchmark connect and handshake timeouts in tests/queries/0_stateless/01600_benchmark_query.sh so slow CI lanes do not leak a SOCKET_TIMEOUT into stderr before the benchmark can load and run SELECT 1. The change is scoped to the flaky stateless test, preserves the existing assertions, and matches the failure mode documented in the PR discussion.

Final Verdict

Status: ✅ Approve

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

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 7ec04d1

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 (arm_asan_ubsan) / Hung check failed, possible deadlock found deadlock (chronic hung-check family; unrelated to this one-line benchmark-timeout test change) #101680 / #105905 (ours, open)

This PR is a one-line test fix to 01600_benchmark_query.sh (raise clickhouse-benchmark connect/handshake timeout for the slow amd_msan+WasmEdge lane). The single failure is the chronic Stress-test hung-check deadlock, not in this PR's changed file. Finish Workflow + Mergeable Check pass on this head.

Session id: cron:our-pr-ci-monitor:20260626-170000

@clickhouse-gh

clickhouse-gh Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.60% +0.00%

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

Newly covered by added/modified tests: 305 line(s), 50 function(s) across 125 file(s) · Details

Top files
  • src/Common/ZooKeeper/ZooKeeperImpl.cpp: 16 line(s)
  • src/AggregateFunctions/TimeSeries/AggregateFunctionTimeseriesLinearRegression.h: 14 line(s), 32 function(s)
  • src/AggregateFunctions/TimeSeries/AggregateFunctionTimeSeriesGroupArray.h: 10 line(s), 8 function(s)
  • src/AggregateFunctions/AggregateFunctionQuantileExactWeighted.cpp: 8 line(s)
  • src/Storages/StorageReplicatedMergeTree.cpp: 7 line(s)

Full report

@alexey-milovidov alexey-milovidov self-assigned this Jun 29, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 29, 2026
Merged via the queue into ClickHouse:master with commit 28ae4c2 Jun 29, 2026
174 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 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]>
pull Bot pushed a commit to AKJUS/ClickHouse that referenced this pull request Aug 5, 2026
The test asserts that a clickhouse-benchmark run logs 3 queries under one
initial_query_id. On a loaded runner it read 0 instead of 3.

The benchmark process never ran its query. Connection::connect uses
handshake_timeout_ms (default 10000, Settings.cpp:410) as the socket receive
timeout for the server Hello read, and clickhouse-test gives the benchmark no
timeout overrides (shell_config.sh builds CLICKHOUSE_BENCHMARK_OPT0 from only
--port, --database and --log_comment, while the client gets connect_timeout and
receive_timeout from the runner). When the accept/handshake path stalls for
longer than 10 s the benchmark exits with SOCKET_TIMEOUT before sending any
query, so query_log has no rows for that query_id and the assertion reads 0.

In the reported run the server accepted no TCP connection for 22.50 s
(21:45:14.247 to 21:45:36.747 in the job's clickhouse-server.log, zero
TCPHandlerFactory accepts in between, and executeQuery starts fell to 0 for the
11 s from 21:45:17 to 21:45:27). The benchmark's connection was accepted at the
end of that window and the server logged "Client has gone away", the benchmark
having already given up. The job's query_log.tsv confirms it: the failing
instance has 0 rows with client_name = 'ClickHouse benchmark', while each of the
6 in-place reruns has exactly 3.

Give connect and handshake a generous budget, matching the same fix already
merged for 01600_benchmark_query (ClickHouse#108570) and present in
03630_benchmark_accept_invalid_certificate and 03636_benchmark_error_messages.
The assertion is unchanged, so what the test verifies is unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
github-actions Bot pushed a commit to Altinity/ClickHouse that referenced this pull request Aug 7, 2026
The test asserts that a clickhouse-benchmark run logs 3 queries under one
initial_query_id. On a loaded runner it read 0 instead of 3.

The benchmark process never ran its query. Connection::connect uses
handshake_timeout_ms (default 10000, Settings.cpp:410) as the socket receive
timeout for the server Hello read, and clickhouse-test gives the benchmark no
timeout overrides (shell_config.sh builds CLICKHOUSE_BENCHMARK_OPT0 from only
--port, --database and --log_comment, while the client gets connect_timeout and
receive_timeout from the runner). When the accept/handshake path stalls for
longer than 10 s the benchmark exits with SOCKET_TIMEOUT before sending any
query, so query_log has no rows for that query_id and the assertion reads 0.

In the reported run the server accepted no TCP connection for 22.50 s
(21:45:14.247 to 21:45:36.747 in the job's clickhouse-server.log, zero
TCPHandlerFactory accepts in between, and executeQuery starts fell to 0 for the
11 s from 21:45:17 to 21:45:27). The benchmark's connection was accepted at the
end of that window and the server logged "Client has gone away", the benchmark
having already given up. The job's query_log.tsv confirms it: the failing
instance has 0 rows with client_name = 'ClickHouse benchmark', while each of the
6 in-place reruns has exactly 3.

Give connect and handshake a generous budget, matching the same fix already
merged for 01600_benchmark_query (ClickHouse#108570) and present in
03630_benchmark_accept_invalid_certificate and 03636_benchmark_error_messages.
The assertion is unchanged, so what the test verifies is unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
(cherry picked from commit 7199612)
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…nchmark-query-handshake-timeout

Fix flaky test 01600_benchmark_query
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.

4 participants