Repository navigation
Give the native handshake in test_default_session_user a deadline that covers a slow reject - #120753
Conversation
…t covers a slow reject test_native_default_session_user_with_password fails only on the amd_llvm_coverage integration shards, with "TimeoutError: timed out" at native_hello's sock.recv(1): 3 failures over 7,621 coverage rows in 30 days, across three unrelated PRs (one of them documentation-only), and 0 master failures in 90 days. A rejected native login is answered only after two symbolized stack traces are rendered. The first comes from the catch in AccessControl::authenticate (src/Access/AccessControl.cpp:629); the second from writeException (src/IO/WriteHelpers.cpp:77-85), reached through TCPHandler::runImpl's sendException (src/Server/TCPHandler.cpp:507, :531) with the server context's calculate_text_stack_trace, and the packet reaches the wire only after it. Since StackTrace::toStringCached keys on the exact frame-pointer triple, the two distinct exceptions each pay a full DWARF symbolization. In the failing job's log (PR ClickHouse#115680 / 4ee5eff, coverage 2/8) those renders took 8.59s and 10.35s, so the client's first byte arrived 18.9s after connect; a second case in the same run took 16.6s. The helper allowed 10s. Nothing here is a server defect: coverage binaries are never shipped, the same renders cost 0.04s once the DWARF is parsed, and the logging is deliberate (AccessControl.cpp:661-663). The server's handshake_timeout_milliseconds is checked only before a read (src/IO/ReadBufferFromPocoSocket.cpp:106), which is why the answer does arrive at 18.9s instead of the connection being dropped. 60s is not an arbitrary pick: 60000ms is the value this repository already uses for a handshake read deadline on a slow lane, in six places. One is 00563_shard_insert_into_remote.sql (SET handshake_timeout_ms = 60000, by Alexey Milovidov, d4fed63); four are my own merged CI fixes (01600, 02040, 03630, 03443), each commented that the default 10s handshake_timeout_ms is not enough on slow lanes; stress_tests.lib:362 uses 30s. Two samples fix the order of magnitude of a first-time symbolization on a loaded runner, not its tail, so a deadline just above the observed maximum would re-flake. The cost is bounded: this is a deadline rather than a sleep, so a passing call pays nothing, native_hello has no retry loop, and pytest.ini's timeout = 900 still catches a genuine hang. The client's own handshake_timeout_ms default is also 10s, but that setting is an SLA for a real connection deciding when to fail over. This read only observes whether a login was rejected and asserts nothing about latency, so a client-realistic deadline adds no assertion value and only decides how often the observation is lost. Alternatives rejected: suppressing either render removes deliberate diagnostics on a security-relevant path; calculate_text_stack_trace=0 in the test profile would leave render ClickHouse#1 at 8.59s, i.e. 86% of a 10s budget, and weaken diagnostics for the module's other tests; skipping the case under coverage deletes reject-path coverage on the flavour whose purpose is measuring it. Two other hand-rolled native Hello sites are deliberately left alone. test_interserver_marker_requires_cluster_secret rethrows in interserver mode at TCPHandler.cpp:521-526 before sendException, so the packet-gating render is structurally absent and its oracle is a closed connection; it has never failed with this signature. In test_tcp_hello_string_limits a client timeout is part of the oracle (a rejection arm returns False on socket.timeout), and that module shortens the server's handshake timeout to 3000ms on purpose. Validation: with the coverage binary from the failing job the module passes 30/30 and the three native_hello callers pass 10 times each. The failure is reproduced deterministically against a stub listener answering after 15s: before this change the helper raises TimeoutError at sock.recv(1) in 10.01s, the exact CI frame; after it, the helper returns the Exception packet at 15.00s. A never-answering stub fails at 10s before and 60.00s after, so the constant is the operative variable, and an arm answering ServerHello instead still reddens the assertion in 0.05s. The 18.9s magnitude is measured in CI and is not reproducible on an idle box, where the same binary answers a reject in 0.105s. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings; it read the full changed
Also considered and rejected: tagging the case out of the coverage flavour, which is the remedy the Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-49:20260918-073800 |
|
Workflow [PR], commit [53225ee] Summary: ✅ AI ReviewSummaryThis PR narrows the timeout change in Final VerdictStatus: ✅ Approve |
socket.create_connection(address, timeout=T) installs T on the socket before connect and leaves it installed, so widening it for the slow reject response also widened connection establishment for all 14 native_hello assertions in this module: a blackholed port would then burn 60s per call instead of 10s before the real failure becomes visible. Every observed occurrence of this flaky failure timed out in recv(1), never in create_connection, so only the response read needs the wider deadline. Measured with native_hello loaded from the test file itself, against a stub whose response latency is controlled and against a port whose accept queue is saturated so its SYNs are dropped. Before: a blackholed connect raised TimeoutError after 60.06s, and the live socket reported connect/recv deadlines of 60.0/60.0. After: 10.01s, and 10.0/60.0 with settimeout(60) observed before recv. Unchanged by this commit: a 15s-delayed reject still returns the exception packet at 15.00s, an immediate wrong answer still fails in 0.00s, and a server that never answers still fails at 60.06s, 15x inside the 900s pytest-timeout cap.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Give the response read of the hand-rolled native Hello helper in the
test_default_session_userintegration test a 60s deadline, so that a rejected login is still observed on a coverage-instrumented server.Description
test_default_session_user/test.py::test_native_default_session_user_with_passwordfails only onIntegration tests (amd_llvm_coverage, N/8), withTimeoutError: timed outatnative_hello'ssock.recv(1): 3 failures over 7,621 coverage rows in 30 days, on three unrelated PRs (one documentation-only), and 0 master failures in 90 days.Root cause: a rejected native login is answered only after two symbolized stack traces are rendered, in
AccessControl::authenticate'scatchand insidewriteException, which flushes the packet afterwards. In the failing job's log those renders took 8.59s and 10.35s: the first response byte arrived 18.9s after connect.This gives only that read 60s, installed after the Hello is sent, so connection establishment keeps its 10s deadline and an unreachable listener still fails fast. 60000ms is what this repo already uses for a handshake read deadline on a slow lane, in five places:
00563_shard_insert_into_remote.sql(by Alexey Milovidov) and four earlier CI fixes of mine (01600, 02040, 03630, 03443).The client's own
handshake_timeout_msdefault is also 10s, but that is a failover SLA, not a bound on observing a rejection. A hung server still fails at 60s, inside the 900s pytest cap.Validation: against a stub answering after 15s the failure reproduces: pre-change
TimeoutErroratsock.recv(1)in 10s, the exact CI frame; post-change the Exception packet at 15s. Against a saturated accept queue, connect still gives up in 10.01s. 18.9s is a CI measurement; on an idle box the same binary rejects in 0.1s.Deliberately unchanged, none with a timeout failure in 90 days:
postgres_loginand the web-terminal socket in this file (one render each, not the two that gate a native reject),test_interserver_marker_requires_cluster_secret(rethrown beforesendException, so no render gates a packet) andtest_tcp_hello_string_limits(a client timeout is part of its oracle).CI provenance: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115680&sha=4ee5eff0aca01d92279bfa3fc109a743eefbf9a1&name_0=PR&name_1=Integration%20tests%20%28amd_llvm_coverage%2C%202%2F8%29
Workflow [PR]
Sync PR [sync-upstream/pr/120753]
Version info
26.10.1.153(included in26.10and later)