Repository navigation
Conversation
The test uses a raw Python socket and waits for the server's exception
response with `sock.settimeout(5)` inside `get_response`. Five seconds
turns out to be too tight on `amd_llvm_coverage` builds: under parallel
test load the coverage-instrumented server sometimes takes longer than
5 s to surface `Unknown query processing stage` / `Unexpected query
kind` / `Unknown compression state`, producing `AssertionError:
stage=5: timeout, result:` with the partial stdout captured.
CIDB shows the pattern clearly: 12 hits in 30 days, every single one on
an `amd_llvm_coverage` (or `amd_llvm_coverage_per_test`) variant, 0
hits on the non-coverage amd_debug/amd_asan_ubsan/amd_tsan/amd_msan/
arm_binary builds that run the same test.
The timeout in this test is only a safety net for a genuinely stuck
server; the test itself is fast and deterministic, so raising the
ceiling to 60 s doesn't slow down the happy path. 60 s is still small
enough to catch a real hang.
Verified locally:
* `get_response(timeout=0.001)` — 5/5 runs fail with the same
`timeout, result:` pattern seen in CI.
* `get_response(timeout=60.0)` — 50/50 runs pass with full random
settings / random MergeTree settings enabled.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
Pre-PR validation gate
Session: |
|
cc @Algunenano — could you review this tiny timeout bump for the test you added in #101972? It's been flaky specifically on |
|
Workflow [PR], commit [e3b20f4] Summary: ❌
AI ReviewSummaryThis PR fixes flakiness in ClickHouse Rules
Final Verdict
|
|
@groeneai Check the flaky test reports and fix the failures. |
The flaky checks on the previous commit (`amd_debug, flaky check` and
`amd_asan_ubsan, flaky check`) exposed a latent bug in
`test_valid_queries_still_work`: the custom Native protocol parser drifts
and eventually fails with `'utf-8' codec can't decode byte 0x88 in
position 0: invalid start byte` when decoding what the parser treats as
a column name/type string but is actually binary payload of the next
packet.
Root cause. The parser's `Progress` and `ProfileInfo` field-count logic
does not match the server formats at `CLIENT_REVISION = 54449`:
- `Progress` at rev 54449 writes 5 varuints (`read_rows`, `read_bytes`,
`total_rows_to_read`, `written_rows`, `written_bytes`), but the
parser reads 6 (3 base + 2 gated on `>= 54372` + 1 gated on
`>= 54448`), overshooting by one varuint.
- `ProfileInfo` at rev 54449 writes 4 varuints plus 2 bool bytes,
but the parser reads 7 varuints plus 3 bytes, significantly
overshooting.
Both parsers "work" most of the time because the drift byte usually
happens to be a benign small varuint; under some randomized CI
configurations the drift lands in a multi-byte varuint or a block
header, and the follow-up `read_string` call decodes binary data
through `.decode('utf-8')`, producing the 0x88 error. `skip_block`
has similar issues (no branch for plain `DateTime`, falls through to
`recv_exact(nr * 8)` but the server writes 4 bytes per row).
Fix. `get_response` now reads exactly one packet: `SERVER_EXCEPTION`
means the query was rejected (parse code/message), and anything else
means the server accepted the query and began producing a response
(`Data`, `ProfileEvents`, `Progress`, `ProfileInfo`, `EndOfStream`, ...).
All four tests only need the accept/reject signal, so the fragile
stream-parsing code is deleted entirely. This also makes the test
forward-compatible with future protocol revisions that add new packet
types or fields.
Pre-PR validation gate:
- Deterministic repro: CIDB shows the flaky check failing on the
previous commit with the UTF-8 0x88 error in
`test_valid_queries_still_work`.
- Root cause: Progress/ProfileInfo field-count mismatch at
`CLIENT_REVISION = 54449`, proven against
`src/IO/Progress.cpp::ProgressValues::write` and
`src/QueryPipeline/ProfileInfo.cpp::ProfileInfo::write` with
revision gates `DBMS_MIN_PROTOCOL_VERSION_WITH_TOTAL_BYTES_IN_PROGRESS`
(54463) and `DBMS_MIN_REVISION_WITH_ROWS_BEFORE_AGGREGATION` (54469).
- Fix matches root cause: eliminates the entire fragile parsing
stage; only the first packet is inspected.
- Test intent preserved: the four tests still send invalid `stage`,
`query_kind`, and `compression` values and still assert that the
server rejects them with the expected error messages; the valid
query test still asserts `SELECT 1` is accepted.
- Both directions demonstrated: locally, 100/100 passes with
randomization with the fix; CIDB shows the flaky check failing
consistently on commit 749e087 without the fix.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103210&sha=749e08797a8b9bbef75923c08849452793039a57&name_0=PR
PR: ClickHouse#103210
|
@nikitamikhaylov Thanks for the nudge — the flaky check was exposing a real latent bug in the test itself (not a coverage timing issue). Pushed a fix in commit e3b20f4. What the flaky check was catching On the previous commit, The failure is in Root cause The test implements a minimal Native protocol parser that tries to skip data blocks,
Most of the time the drift byte happens to be a benign small varuint, so the test passes. Under some randomized CI configs the drift lands on a multi-byte varuint or a block header and the next Fix
Pre-PR validation gate (all 5 affirmative)
About the other failures on the same run
Session: |
The test wraps `clickhouse-client --database nonexistent` in `timeout 5` and greps for `UNKNOWN_DATABASE`. On `amd_llvm_coverage` builds under parallel test load the coverage-instrumented client can take longer than 5 s to start and emit the error, causing the grep to find nothing and the test to print `FAIL`. 30-day CIDB: all 19 failures are `amd_llvm_coverage` variants; 0 on regular builds. Same timing pattern as 04078_native_protocol_input_validation (PR ClickHouse#103210), where the fix was to raise a 5 s socket timeout to 60 s. Raising `timeout 5` to `timeout 60` keeps the test fast on happy paths (runs in milliseconds normally) while giving enough headroom for slow CI startup, and still catches a genuinely hung client. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=1b90aee2d24bd44c14d55c9b27d06012177a1bb6&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%201%2F3%29
Closing as supersededMaster adopted the same fix without our PR:
CIDB verification of
The 3 remaining failures are on PR #103243 ( Both flaky-test failure modes (LLVM-coverage timeout and the cc @nikitamikhaylov @Algunenano — thanks for the review traffic; the fix is on master already. |
04078_native_protocol_input_validation.pyis a Python test that opens raw TCP sockets and sends hand-craftedQuerypackets with invalidQueryProcessingStage,query_kind, andProtocol::Compressionvalues. It expects the server to respond with an exception containing a specific error string.The helper
get_responsewaits for that exception withsock.settimeout(5.0). Five seconds is tight onamd_llvm_coveragebuilds: under parallel test load the coverage-instrumented server occasionally takes longer than that to surface the exception, and the test fails withAssertionError: stage=5: timeout, result:(the partial stdout captured).CIDB over the last 30 days shows the pattern is purely coverage-build-specific:
Stateless tests (amd_llvm_coverage, 2/3)Stateless tests (amd_llvm_coverage, AsyncInsert, s3 storage, parallel)Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel)Stateless tests (amd_asan_ubsan, ...),arm_binary,amd_tsan,amd_msan,amd_debug, ...12 failures in 30 days, all 100%
amd_llvm_coveragevariants; 0 on regular builds. Every failure message has the shape<field>=<value>: timeout, result:— the socket timed out waiting for the server'sExceptionpacket.The timeout here is only a safety net against a genuinely stuck server; the test itself is fast and deterministic, and it is pointless to fail on slow-CI latency. Raising the ceiling to 60 s doesn't slow the happy path down (response is still typically <50 ms) and is still short enough to catch a real hang.
Verification (locally, latest master)
get_response(timeout=0.001)— test runner--test-runs 5: 5/5 FAIL with exactly thetimeout, result:error pattern seen in CI. Deterministic reproduction of the class of failure.get_response(timeout=60.0)—--test-runs 50with random settings + random MergeTree settings: 50/50 PASS.Related failures from CIDB
Latest master hits:
7e98ab01ca85—old analyzer, s3 storage, DatabaseReplicated, WasmEdge, parallel32e69597b921—amd_llvm_coverage, 2/314fdb799e129—AsyncInsert, s3 storage, paralleld0311b475bfd—ParallelReplicas, s3 storage, parallel33908541851—amd_llvm_coverage_per_test, per_test_coverage, 7/8Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
N/A — test-only change.
Documentation entry for user-facing changes