Repository navigation
Relax brittle 'receive timeout' assertion in test_distributed_frozen_replica - #103780
Conversation
…replica
The test asserted that the error from a failed clusterAllReplicas query
contains the literal substring "receive timeout 857 ms" — the configured
`handshake_timeout_ms`.
That phrasing is only emitted by the async `HedgedConnections` /
`AsyncTaskExecutor` socket-timeout code path
(`src/Client/HedgedConnections.cpp:449`,
`src/Common/AsyncTaskExecutor.cpp:124`). The synchronous
`ReadBufferFromPocoSocket::nextImpl` path
(`src/IO/ReadBufferFromPocoSocket.cpp:88`) and the ProxyV1 handler path
(`src/Server/ProxyV1Handler.cpp:124`) both format the same error
without the "receive timeout" prefix:
"Timeout exceeded while reading from socket (peer: ..., local: ..., {} ms)"
"Timeout exceeded while reading from socket ({}, {} ms)"
When the 857ms handshake fires through the synchronous path (more
likely on slow sanitizer builds — observed mostly on `amd_msan`,
`amd_tsan`, `amd_asan_ubsan, db disk, old analyzer`), the error
contains "857 ms" but not "receive timeout 857 ms", so the assertion
fails.
All three timeout-error formats include the timeout value as
"{} ms", so check for "857 ms" alone. The test still verifies that the
configured handshake timeout took effect — it just no longer locks the
assertion to one specific socket-error code path.
Failure history: ~10 hits across 9 distinct PRs over the last 30 days.
CI report data: https://play.clickhouse.com/
|
Pre-PR validation gate (per a) Deterministic repro? — Yes, in the CI evidence form: CIDB has 10 failures across 9 unrelated PRs over the last 30 days where The 857-ms handshake-timeout cancellation surfaces through b) Root cause explained? — Yes. The codebase emits the same logical event ("socket read hit configured timeout") through four format-string sites:
When c) Fix matches root cause? — Yes. Replace d) Test intent preserved? — Yes. The test still asserts:
The narrower regression class the previous assertion accidentally caught — "the message format is exactly the async-path one" — was never the test's intent; it was a side effect of which path happened to fire on the original developer's machine. e) Both directions demonstrated? — Asymmetric demonstration:
The fix is a one-line test-only change with no production C++ touched, no behavior gated, and no risk of false positives in the relaxed assertion (the value Tracker task: Session: |
|
cc @azat — could you review this? It's a one-line test-only change in |
|
Workflow [PR], commit [c0214e8] Summary: ✅ AI ReviewSummaryThe PR updates a brittle integration-test assertion in ClickHouse Rules
Final Verdict
|
…heck The test previously asserted that pausing `node1` would cause `clusterAllReplicas(test_cluster, default.local_table)` to fail with `ALL_CONNECTION_TRIES_FAILED`. `cluster.pause_container` uses Docker's cgroup freezer, which takes effect quickly but not synchronously with in-flight TCP traffic, so the SELECT can race the freezer: `node1` can complete the TCP handshake and the tiny server greeting before being suspended, every per-replica shard succeeds, and the query returns a clean `count()` with `error == ''`. The assertion then fails spuriously. This is the chronic flake tracked under issues ClickHouse#103819 and ClickHouse#103820, which surfaced after the `857 ms` formatting fix in PR ClickHouse#103780. Fix: poll a fast probe `SELECT 1 FROM remote('node1:9000', system.one)` inside the pause context until it raises `QueryRuntimeException`. Once that probe fails, connections to `node1` are demonstrably blocked and the actual `clusterAllReplicas` test can run deterministically. The 30-second deadline accommodates slow CI runners; in practice the probe fails on the first or second iteration. The original assertions (`ALL_CONNECTION_TRIES_FAILED in error`, `857 ms in error`) are unchanged — the fix only removes the timing race.
…heck The test previously asserted that pausing `node1` would cause `clusterAllReplicas(test_cluster, default.local_table)` to fail with `ALL_CONNECTION_TRIES_FAILED`. `cluster.pause_container` uses Docker's cgroup freezer, which takes effect quickly but not synchronously with in-flight TCP traffic, so the SELECT can race the freezer: `node1` can complete the TCP handshake and the tiny server greeting before being suspended, every per-replica shard succeeds, and the query returns a clean `count()` with `error == ''`. The assertion then fails spuriously. This is the chronic flake tracked under issues #103819 and #103820, which surfaced after the `857 ms` formatting fix in PR #103780. Fix: poll a fast probe `SELECT 1 FROM remote('node1:9000', system.one)` inside the pause context until it raises `QueryRuntimeException`. Once that probe fails, connections to `node1` are demonstrably blocked and the actual `clusterAllReplicas` test can run deterministically. The 30-second deadline accommodates slow CI runners; in practice the probe fails on the first or second iteration. The original assertions (`ALL_CONNECTION_TRIES_FAILED in error`, `857 ms in error`) are unchanged — the fix only removes the timing race.
|
Backporting to fix CI in 26.3 and 26.4 |
Backport #103780 to 26.3: Relax brittle 'receive timeout' assertion in test_distributed_frozen_replica
…ssertion in test_distributed_frozen_replica
The integration test
test_distributed_frozen_replica/test.py::test_cluster_all_replicas_queryfails intermittently because it asserts the literal substring"receive timeout 857 ms"(the configuredhandshake_timeout_ms) appears in the failure message — but only one of three socket-timeout code paths produces that exact phrasing.Root cause
Three places in the codebase format socket-read-timeout errors:
src/Common/AsyncTaskExecutor.cpp:124(async I/O fiber)({}, receive timeout {} ms)src/Client/HedgedConnections.cpp:449(hedged-connection failover)({}, receive timeout {} ms)src/IO/ReadBufferFromPocoSocket.cpp:88(synchronous Poco read)(peer: {}, local: {}, {} ms)src/Server/ProxyV1Handler.cpp:124(Proxy v1 wire handler)({}, {} ms)All four formats include the timeout value formatted as
{} ms. When the 857-ms handshake fires through the synchronousReadBufferFromPocoSocketpath (more likely on slow sanitizer builds — observed mostly onIntegration tests (amd_msan, 1/6),(amd_tsan, 1/6), and(amd_asan_ubsan, db disk, old analyzer, 1/6)), the assertion fails because the error contains857 msbut notreceive timeout 857 ms.Example failing CIDB log (
pull_request_number=100399,Integration tests (amd_msan, 1/6)):The only
receive timeoutphrase here is for the unrelated default-5000ms socket-receive timer. The 857-ms handshake-timeout cancellation surfaces through the sync path and prints857 mswithout the prefix.Fix
Relax the assertion from
"receive timeout 857 ms"to"857 ms". The test still verifies the configuredhandshake_timeout_ms=857actually took effect (the value appears in the error), but no longer locks the assertion to one specific socket-error code path. The companion assertion"ALL_CONNECTION_TRIES_FAILED" in erroralready verifies the high-level failure mode.Failure history
Over the last 30 days, ~10 failures across 9 distinct unrelated PRs in the assertion-mismatch mode (this PR's target). Concentrated on slow sanitizer + old-analyzer integration runners.
CI report data: https://play.clickhouse.com/
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.5.1.201(included in26.5and later)26.3.33.59