Skip to content

Do not treat a transient liveness-probe timeout as a dead fuzzer server - #108582

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-fuzzer-liveness-probe-timeout
Jun 27, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-fuzzer-liveness-probe-timeout

Conversation

@groeneai

@groeneai groeneai commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #108508

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

The AST fuzzer (...) job intermittently reports a Received signal 15 failure across unrelated PRs (8 PRs in the last 30 days on arm_asan_ubsan, amd_msan, amd_tsan, amd_debug-targeted; 0 on master). The reported row has no STID, no stack, and no fuzzed query.

Root cause. It is a false positive in the post-fuzz server-liveness probe, not a crash. After the fuzzer is SIGTERM'd at its 30m time limit (a clean run, fuzzer_exit_code=143), run-fuzzer.sh probes the server with clickhouse-client --receive_timeout=5 --query "SELECT 1". When that first probe hits its 5s receive timeout (the server is alive but slow to answer right after 30m of ASAN fuzzing), the loop's catch-all else branch sets server_died=1 and breaks on the first failure. status.tsv then carries server_died=1, and ast_fuzzer_job.py checks server_died before the fuzzer_exit_code in (0, 137, 143) OK branch, so the healthy run is reported as a FAIL whose only "stack" is the server's normal-shutdown Received signal 15 line. stop_server confirms it in the same logs (Server exit code is 0) — the server shut down cleanly and was never dead.

Evidence from the triggering run (PR #108508, SHA 88795dc6caed, AST fuzzer (arm_asan_ubsan), report):

  • 04:11:26 fuzzer started (30m budget); 04:41:26 (+30m) timeout --signal TERM → fuzzer exit 143, server_died=0.
  • 04:41:32 post-fuzz probe → Timeout exceeded while receiving data from server. Waited for 5 seconds → catch-all sets server_died=1, breaks.
  • 04:41:46 Server exit code is 0 (clean shutdown). fuzzer.log ends at Fuzzing step 602 out of 1000 then timeout: sending signal TERM — no ASan/LOGICAL_ERROR/signal 11/6. server.log has only Received signal 15/Received signal -2 shutdown markers, no <Fatal>, no sanitizer report, no OOM.

Fix. A receive/socket timeout means the server is alive but slow, not dead — a dead server returns Connection refused (code 210) or EOF (code 32), neither of which contains Timeout. The loop now counts consecutive probe timeouts and only declares a hang once they persist (12 in a row), so a single transient timeout no longer turns a clean run into a bogus server died FAIL, while a genuine hang is still caught. The existing Connection refused/EOF path is unchanged, so a real dead server is still detected immediately.

ci/tests/test_fuzzer_liveness_loop.py drives the loop text verbatim against a mock clickhouse-client for three cases: transient-timeout-then-recovers (server_died=0), connection-refused (server_died=1 on the first probe), and persistent-timeout/hang (server_died=1 once it persists). The transient case fails against the pre-fix loop and passes after the fix.

Version info

  • Merged into: 26.7.1.160 (included in 26.7 and later)

After the AST fuzzer is SIGTERM'd at its 30m time limit (a clean run, exit
143), run-fuzzer.sh probes the server with `clickhouse-client
--receive_timeout=5 --query "SELECT 1"`. If that first probe hit its 5s
receive timeout (the server is alive but slow to answer right after 30m of
ASAN fuzzing), the loop's catch-all branch set server_died=1 and broke on the
first failure. status.tsv then carried server_died=1, and ast_fuzzer_job.py
checks server_died before the exit-143 OK branch, so the healthy run was
reported as a FAIL whose only "stack" is the server's normal-shutdown
"Received signal 15" line.

A receive/socket timeout means the server is alive but slow, not dead: a dead
server returns "Connection refused" (code 210) or EOF (code 32), neither of
which contains "Timeout". Count consecutive probe timeouts and only declare a
hang once they persist (12 in a row, ~12s), so a single transient timeout no
longer turns a clean run into a bogus "server died" failure while a genuine
hang is still caught. The busy branches reset the counter so it tracks
consecutive timeouts only.

Observed across 8 unrelated PRs in 30 days (arm_asan_ubsan, amd_msan,
amd_tsan, amd_debug-targeted), 0 on master.

Adds ci/tests/test_fuzzer_liveness_loop.py, which drives the loop text
verbatim against a mock clickhouse-client for the transient-recovery,
connection-refused, and persistent-hang cases.

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. ci/tests/test_fuzzer_liveness_loop.py drives the loop verbatim against a mock clickhouse-client: the transient-timeout-then-recovers case deterministically yields server_died=1 on the pre-fix loop and server_died=0 after the fix. The CI signature itself is also deterministic given the inputs (fuzzer_exit_code=143 + a single 5s receive timeout on the first post-fuzz probe).
b Root cause explained? Yes. After the fuzzer is SIGTERM'd at its 30m limit (clean run, exit 143), the post-fuzz SELECT 1 probe (--receive_timeout=5) hits a 5s timeout because the server is alive but slow right after 30m of ASAN fuzzing. The loop's catch-all else treated that timeout as server_died=1 and broke. ast_fuzzer_job.py checks server_died before the exit-143 OK branch, so the healthy run is FAILed and FuzzerLogParser scrapes the server's normal-shutdown Received signal 15 line. stop_server logged Server exit code is 0 — the server was never dead.
c Fix matches root cause? Yes. The fix distinguishes "alive but slow" (a receive/socket Timeout exceeded while ...) from "dead" (Connection refused/EOF, which contain no Timeout). It retries on timeout and only declares a hang after 12 consecutive timeouts — directly targeting the single-transient-timeout misclassification, not a symptom.
d Test intent preserved / new tests added? Yes. New ci/tests/test_fuzzer_liveness_loop.py extracts the loop text verbatim (BEGIN/END markers) and asserts all three behaviors. The dead-server and persistent-hang detection paths are unchanged and covered by tests.
e Both directions demonstrated? Yes. The transient-recovery test FAILS against the pre-fix loop (wrongly server_died=1) and PASSES after the fix; the connection-refused and persistent-hang tests pass in both.
f Fix is general across code paths? Yes. This loop is the only post-fuzz liveness probe in run-fuzzer.sh. The sibling stress_job.py/stress.py server-death checks use a different (Python) mechanism and are not affected by this timeout misclassification.
g Fix generalizes across inputs? Yes. The new branch matches the whole client/socket timeout family (Timeout exceeded while receiving data from server, Timeout exceeded while reading/writing to socket — all contain Timeout exceeded while), while a dead server (Connection refused code 210, EOF code 32) still has no Timeout substring and takes the immediate-death branch. The TOO_MANY_SIMULTANEOUS_QUERIES/MEMORY_LIMIT_EXCEEDED branches reset the consecutive-timeout counter so they are not affected.
h Backward compatible? N/A — CI-harness behavior only; no server settings, on-disk/wire formats, or user-facing behavior changed.
i Invariants and contracts preserved? Yes. The loop's contract is unchanged: it still sets server_died=1 and breaks for a genuinely dead/hung server and server_died=0 when the server responds; only the misclassification of a transient timeout is corrected. status.tsv (3 fields: server_died, server_exit_code, fuzzer_exit_code) is still written exactly once at the end. Worst-case added latency is bounded (12 × 5s probe + sleeps), well within the job budget; a real hang is still caught.

Session id: cron:clickhouse-worker-slot-1:20260626-071200

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv — could you review this CI fix? It stops the AST fuzzer job from reporting a bogus Received signal 15 FAIL when the post-fuzz SELECT 1 liveness probe hits a transient 5s receive-timeout on a clean (exit 143) run: a receive timeout means the server is alive but slow, not dead, so the loop now retries and only declares a hang after repeated consecutive timeouts.

@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [64bc255]

Summary: ✅


AI Review

Summary

This PR changes ci/jobs/scripts/fuzzer/run-fuzzer.sh so a single post-fuzz clickhouse-client receive timeout is treated as an alive-but-slow server and only marks server_died=1 after repeated consecutive timeouts. It also adds a focused Python regression test that extracts the marked shell loop and covers transient timeout recovery, immediate Connection refused, and persistent timeout behavior. I found no blocking correctness or safety issues.

Missing context / blind spots
  • ⚠️ Local pytest is not installed in this checkout environment, so I could not run the new test through pytest collection locally. I ran the three test functions directly with temporary directories and all passed; the Praktika report for the PR shows no failed jobs.
Final Verdict

Status: ✅ Approve

No required actions.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 26, 2026
@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Jun 26, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 27, 2026
Merged via the queue into ClickHouse:master with commit 96509b5 Jun 27, 2026
329 of 330 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 27, 2026
clickgapai pushed a commit to clickgapai/ClickHouse that referenced this pull request Aug 22, 2026
The post-fuzz liveness probe loop in run-fuzzer.sh is written to spend 5 seconds
per probe, but each probe can block for 300 seconds. On PR ClickHouse#111394's
AST fuzzer (amd_debug, targeted) job the loop took 66 minutes to reach its
verdict: 5m27s per probe, twelve times.

--receive_timeout does not apply until the handshake completes. Connection.cpp
sets both socket timeouts to handshake_timeout before sendHello and only swaps
them to receive_timeout/send_timeout afterwards, and the client CLI's handshake
fallback is DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC * 1000 = 300000 ms, even though the
setting's own declared default is 10000. A server that accepts the TCP
connection but never finishes the handshake therefore holds each probe for
300 seconds. The fuzzer's port is TLS and the TLS handshake is deferred to the
first send, so the error text reads "writing to socket", which invites a wrong
attribution to send_timeout; elapsed time discriminates the two.

Measured against a listener that accepts and never replies: --receive_timeout=5
alone blocks 300s (322s over TLS); adding --handshake_timeout_ms=30000 bounds it
at 30s, and 5000 and 12000 confirm the bound tracks the value passed.

30000 rather than 10000 because 7ec04d1 documents a healthy server
needing more than 10s to send Hello on a loaded lane, and a retry does not help
since each attempt spawns a fresh client and restarts the handshake from zero.
The worst healthy handshake measured on a debug server under 65 concurrent
queries was 0.148s, so the margin is large.

The two best-effort diagnostics get a hard command deadline instead of a flag: a
diagnostic can stall pre-Hello, post-Hello or inside the query itself, and one
wall-clock cap covers all three. --kill-after is required because a bare timeout
only sends SIGTERM and then keeps waiting: measured 12s for a 3s budget against
a child that ignores it. Both call sites were already ||:-guarded, so the signal
cannot abort the script before the status.tsv write.

No loop bound, branch or verdict is changed. Running the loop's five outcomes
(immediate success, connection refused, persistent timeout,
TOO_MANY_SIMULTANEOUS_QUERIES, MEMORY_LIMIT_EXCEEDED) against the patched and
unpatched text gives identical results, including the final timeouts counter;
two mutations of the loop do shift those results, so the comparison is not
vacuous. In particular timeouts_max stays at 12, since lowering it would weaken
the anti-false-positive property added in ClickHouse#108582.

This does not fix whatever wedged the server and would not have turned the cited
run green: that server genuinely failed 12 consecutive probes, so the job fails
either way. What it removes is about 54 minutes of wasted runner time per
occurrence, and three reachable scenarios whose worst case exceeds the 5 hour job
cap today (bootstrap readiness, post-gdb readiness, and all-busy probing) now
peak at 188 minutes.
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…r-liveness-probe-timeout

Do not treat a transient liveness-probe timeout as a dead fuzzer server
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.

5 participants