Skip to content

CI: keep 159 and 209 out of the LogCluster green path - #121393

Merged
alexey-milovidov merged 1 commit into
masterfrom
ci-log-cluster-transient-codes-query-verdicts
Sep 21, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
ci-log-cluster-transient-codes-query-verdicts

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

LogCluster._classify treated exception codes 159 (TIMEOUT_EXCEEDED) and 209 (SOCKET_TIMEOUT) as LogClusterUnavailable, so they reached the green handler of main in ci/jobs/build_profile_diff_job.py and reported the "Build profile diff" 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 SELECTs, 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.

This is the review finding that was left unresolved on #121048 when it merged.

Related: #121048
Related: #118708

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/121393]

Version info

  • Merged into: 26.10.1.393-master (included in 26.10 and later)

`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]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6a2e21a]

Summary: ✅


AI Review

Summary

This PR narrows the LogCluster green path so TIMEOUT_EXCEEDED and SOCKET_TIMEOUT no longer let Build profile diff report OK after the server answered with a query failure. The classification change itself is consistent with the contract in report_cluster_unavailable, but it still ships without committed regression coverage for the exception-code boundary.

Findings

⚠️ Majors

  • [ci/jobs/scripts/log_cluster.py:354] The PR changes which server exceptions turn the check green versus red, but there is still no in-tree test proving the boundary for 159, 209, 202, 241, and headerless 5xx. This repo already carries ci/tests pytest coverage for CI Python jobs, so relying on a throwaway harness leaves the original false-green path easy to reintroduce silently in a later refactor. Suggested fix: add a focused ci/tests case that stubs the response header/status combinations and asserts 159 / 209 raise LogClusterQueryError, 202 / 241 stay LogClusterUnavailable, and headerless 502 / 503 remain LogClusterUnavailable.
Tests
  • No committed automated regression test was added for the new classification behavior.
Final Verdict

Changes requested.

LLVM Coverage Report

⚠️ No coverage measurement for commit 6a2e21a: incomplete coverage measurement: 16 of 21 shard profiles are missing: LLVM_COVERAGE_FILE_ft_2.profdata, LLVM_COVERAGE_FILE_ft_3.profdata, LLVM_COVERAGE_FILE_ft_s3_async_sequential.profdata, LLVM_COVERAGE_FILE_ft_s3_db_repl_parallel_2.profdata, LLVM_COVERAGE_FILE_ft_s3_db_repl_parallel_3.profdata, LLVM_COVERAGE_FILE_ft_s3_db_repl_sequential_1.profdata, LLVM_COVERAGE_FILE_ft_s3_db_repl_sequential_2.profdata, LLVM_COVERAGE_FILE_ft_s3_sequential.profdata, LLVM_COVERAGE_FILE_it_1.profdata, LLVM_COVERAGE_FILE_it_2.profdata, LLVM_COVERAGE_FILE_it_3.profdata, LLVM_COVERAGE_FILE_it_4.profdata, LLVM_COVERAGE_FILE_it_5.profdata, LLVM_COVERAGE_FILE_it_6.profdata, LLVM_COVERAGE_FILE_it_7.profdata, LLVM_COVERAGE_FILE_it_8.profdata.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 21, 2026
# 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})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / 209 raise LogClusterQueryError immediately,
  • 202 / 241 stay retryable LogClusterUnavailable,
  • headerless 502 / 503 remain LogClusterUnavailable.

@groeneai

Copy link
Copy Markdown
Collaborator

Verified 6a2e21ab645a against what the description claims, and it holds: one commit, one file, 14 added and 7 removed, with 1a75e54f4c38 an ancestor, so it sits on the merged classification. The only functional line is the set. _classify's body, the except LogClusterError: raise ordering from 0c06b1809c3d and is_ready returning a bool are untouched.

Behavior measured rather than read, with a stubbed session and time.sleep patched out, 12 assertions:

  • on 6a2e21ab: 159, 209, 164, 158, 395, 62 and 60 raise LogClusterQueryError after exactly one POST; 202 and 241 use all 8 POSTs and end as LogClusterUnavailable; a headerless 502 or 503 does the same; a non-numeric header value falls closed to LogClusterQueryError.
  • on the parent, i.e. the merged {159, 202, 209, 241}: the same assertions fail for exactly two cases, 159 and 209, each taking 8 POSTs and then LogClusterUnavailable. Nothing else changes.

Its own CI: Style check, Code Review and Config Workflow green, Build (arm_tidy) queued, CH Inc sync still running, nothing red. Build profile diff is not among the jobs this run scheduled, so the fix is not gated by the job it fixes.

On the review's ask for a ci/tests case: its premise does not hold. Nothing runs that directory. The only reference to the path anywhere in the tree is a praktika docstring example naming ci/tests/example_1, which no longer exists, no command= in ci/defs/job_configs.py and nothing in ci/workflows/*.py or .github/workflows/* names it, and CIDB has no test row naming any of the ten modules there over the last 7 days. A case added there cannot go red, which is the one protection the finding asks for. That matches your own disposition (#115650 removed the suite together with ci/jobs/ci_tests_job.py and its job config, #114675 and #117138 the rest), so my recommendation is to decline the finding rather than answer it with a file there.

If you want the coverage regardless, the case above is written and measured: 12 assertions, green on 6a2e21ab and red on 1a75e54f4c38 for the two codes this pull request removes. The home that actually runs is the stateless suite rather than ci/tests: 05099_clickhouse_test_keeper_retry_matching.sh module-loads tests/clickhouse-test and asserts on need_retry there. Say the word and I will send it that way.

@clickhouse-gh

clickhouse-gh Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6a2e21ab6 with master d536963b1 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 03f0b2c7e; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

10872 translation units recompiled, 11293 s compile time in total, 10381 of them have a recent master baseline.

Translation unit Master PR Δ vs median
contrib/aws-cmake/__/aws/generated/src/aws-cpp-sdk-s3/source/S3Client.cpp 19.2 s 13.2 s -5.4 s (-29%)

Job report

@alexey-milovidov alexey-milovidov self-assigned this Sep 21, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 21, 2026
Merged via the queue into master with commit ec8aaec Sep 21, 2026
177 checks passed
@alexey-milovidov
alexey-milovidov deleted the ci-log-cluster-transient-codes-query-verdicts branch September 21, 2026 23:37
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 21, 2026
valerypetrov pushed a commit to valerypetrov/ClickHouse that referenced this pull request Sep 24, 2026
… 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants