Repository navigation
CI: keep 159 and 209 out of the LogCluster green path - #121393
Conversation
`LogCluster._classify` treated exception codes `159` (`TIMEOUT_EXCEEDED`)
and `209` (`SOCKET_TIMEOUT`) as `LogClusterUnavailable`, so they reached
`main`'s green handler in `ci/jobs/build_profile_diff_job.py` and
reported the check `OK`.
Both are the server's verdicts on a query it accepted, not statements
about the shared cluster's load, and `_classify` is reached from `select`
only - `is_ready` posts its own constant `SELECT 1` and returns a bool
without consulting the set, and `do_query` retries on the status. So the
only path the two codes affected is the reporting `SELECT`s, and there a
query that regressed into a server-side timeout was retried eight times,
classified as an outage, and hidden behind a green check - exactly what
the contract of `report_cluster_unavailable` excludes.
They bought nothing for the outage that motivated the green path either:
that shape returns no response at all (`ReadTimeout`), which leaves
through the transport handler and is `LogClusterUnavailable` whatever the
set contains.
`TRANSIENT_EXCEPTION_CODES` is now `{202, 241}` - too many simultaneous
queries, and the server-wide memory-pressure windows - both verdicts
about the cluster's own load, and both observed rather than inferred.
Verified with a throwaway harness (not committed - we have no automated
tests for the CI scripts): `159` and `209` now classify as
`LogClusterQueryError` and raise after exactly one POST, `202` and `241`
still classify as `LogClusterUnavailable` and exhaust the eight retries,
a headerless `502`/`503` is still `LogClusterUnavailable`, a non-numeric
header value still falls closed, and `164`, `158`, `62` and `60` are
unchanged.
Follow-up to #121048,
addressing the review finding left unresolved there.
Related: #121048
Related: #118708
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [6a2e21a] Summary: ✅
AI ReviewSummaryThis PR narrows the Findings
Tests
Final VerdictChanges requested. LLVM Coverage Report |
| # about a query it accepted and would let a reporting `SELECT` that | ||
| # regressed into a timeout report the check green. Fail closed on all of | ||
| # them: an outage never answers at all, and that path does not reach here. | ||
| TRANSIENT_EXCEPTION_CODES = frozenset({202, 241}) |
There was a problem hiding this comment.
This changes the green-vs-red boundary for Build profile diff, but there is still no committed regression coverage for the exception-code split. The repo already has ci/tests pytest coverage for CI Python jobs, so keeping the proof in a throwaway harness means a later refactor can silently reopen the original false-green path or accidentally flip the real outage cases.
Please add a focused ci/tests case around LogCluster.select / _classify that stubs the response header and status combinations and asserts:
159/209raiseLogClusterQueryErrorimmediately,202/241stay retryableLogClusterUnavailable,- headerless
502/503remainLogClusterUnavailable.
|
Verified Behavior measured rather than read, with a stubbed session and
Its own CI: On the review's ask for a If you want the coverage regardless, the case above is written and measured: 12 assertions, green on |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units10872 translation units recompiled, 11293 s compile time in total, 10381 of them have a recent master baseline.
|
… wall clock `Build profile diff` is SIGKILLed at its 1800 s job timeout while retrying CI logs cluster reads, so it reds a pull request for an outage of an unrelated shared service and reports no reason at all. LogCluster.select bounds a read by attempt count only (retries=8, timeout=60, plus a 5+10+...+40 = 180 s backoff, so about 684 s worst case for one read, and requests' timeout bounds one socket read rather than the request, so a trickling connection was measured at 185 s for a single attempt). It is never bounded by wall clock, while build_profile_diff_job.py issues 16 db.query reads inside a job whose timeout is 1800 s. Three degraded reads exhaust the window, praktika SIGTERM/SIGKILLs the process, and select never returns and never raises: Db.query cannot propagate, main()'s except LogClusterUnavailable never runs, and the green report_cluster_unavailable completion added in ClickHouse#121048 is unreachable in exactly the window it was written for. The kill also skips update_comment, leaving the comparison comment of an earlier commit of the same pull request in place as if it were the current one. Observed on PR ClickHouse#96662 at head 72541f0, which already contains ClickHouse#121048 and ClickHouse#121393: 18 requests.exceptions.ReadTimeout, zero "LogCluster not ready", and the job killed exactly 1800 s after its process started with no Result at all. Reads were succeeding in between, so the job was crawling at about 420 s per read rather than blocked, which is why the budget is shared across the job's reads instead of applied to each one. A LogCluster instance now takes an optional read budget (default None, so every other caller is unchanged) and select gains one guard at the top of its retry loop, on a spent budget AND a POST already attempted. Both conditions are load-bearing rather than conveniences, for the same reason: the post-loop discriminator is defined by what the attempts did, so any read that leaves the loop having attempted no POST classifies as LogClusterNotReady (red) even though the cluster was answering. Exempting attempt 0 covers the read that starts after the deadline; requiring post_attempted covers the read whose first readiness probe fails transiently, which would otherwise break at the second iteration with nothing attempted. So the budget stops POST retries only, and the readiness schedule, which exists because is_ready fails during the same pressure spikes as the query itself, always keeps its full count. The added cost is bounded and paid at most once per job: a read that never becomes ready spends 8 probes plus the 180 s backoff, about 204 s, and then ends the job. No new green path appears, LogClusterNotReady stays red and TRANSIENT_EXCEPTION_CODES is untouched, so both the rule that only "the cluster never answered" is green and ClickHouse#121393's narrowing that keeps 159 and 209 hard continue to hold. The number is derived from the job's own configured timeout via Info().job_config, following stateful_prep_step_timeout in ci/jobs/functional_tests.py, minus a fixed reserve of 550 s, so 1250 s at the current timeout=1800. The reserve is fixed rather than a fraction because every component of it is independent of the timeout: interpreter startup before the first read, one in-flight POST overrunning its 60 s socket timeout, one already-started backoff, and the reporting tail. The docker image pull is not charged to it, because job.timeout only starts with the job process. Applied to the ClickHouse#96662 timeline the read raises at about 13:21:20 instead, 8.5 minutes before the kill, and the check completes green with the reason and a refreshed comment. The failed-attempt spacing there (65/70/75/80/86/90 s, the 60 s socket timeout plus 5*(retry+1)) identifies the 13:20:43 failure as the seventh attempt of that read, so the guard is next reached after its 35 s backoff; 13:23:14 is the first attempt of the following read, which the change never reaches. Validated against a local HTTP stub over three runs with identical classifications, with a control on the pre-change file that matches wherever no budget is passed, with assertions on the derivation keyed on the real JobConfigs.build_profile_diff_job.timeout, and with a case that pins the readiness behaviour: a spent budget plus one transient probe failure returns the body, while the same case without the post_attempted condition raises LogClusterNotReady. Co-Authored-By: Claude Opus 5 <[email protected]>
LogCluster._classifytreated exception codes159(TIMEOUT_EXCEEDED) and209(SOCKET_TIMEOUT) asLogClusterUnavailable, so they reached the green handler ofmaininci/jobs/build_profile_diff_job.pyand reported the "Build profile diff" checkOK.Both are the server's verdicts on a query it accepted, not statements about the shared cluster's load, and
_classifyis reached fromselectonly -is_readyposts its own constantSELECT 1and returns a bool without consulting the set, anddo_queryretries on the status. So the only path the two codes affected is the reportingSELECTs, and there a query that regressed into a server-side timeout was retried eight times, classified as an outage, and hidden behind a green check - exactly what the contract ofreport_cluster_unavailableexcludes.They bought nothing for the outage that motivated the green path either: that shape returns no response at all (
ReadTimeout), which leaves through the transport handler and isLogClusterUnavailablewhatever the set contains.TRANSIENT_EXCEPTION_CODESis now{202, 241}- too many simultaneous queries, and the server-wide memory-pressure windows - both verdicts about the cluster's own load, and both observed rather than inferred.Verified with a throwaway harness (not committed - we have no automated tests for the CI scripts):
159and209now classify asLogClusterQueryErrorand raise after exactly one POST,202and241still classify asLogClusterUnavailableand exhaust the eight retries, a headerless502/503is stillLogClusterUnavailable, a non-numeric header value still falls closed, and164,158,62and60are unchanged.This is the review finding that was left unresolved on #121048 when it merged.
Related: #121048
Related: #118708
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/121393]
Version info
26.10.1.393-master(included in26.10and later)