Skip to content

CI: "Build profile diff" is green when the CI logs cluster does not answer - #121048

Merged
alexey-milovidov merged 2 commits into
masterfrom
ci-build-profile-diff-green-on-cluster-outage
Sep 21, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
ci-build-profile-diff-green-on-cluster-outage

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

The "Build profile diff" check reads everything it reports from the CI logs cluster, which is shared by the whole CI fleet. That cluster has minutes-long windows where it answers nothing (server-wide memory pressure, Code 241 for every query), plus the usual endpoint, credential and transport outages. A read that never got an answer measured nothing about the pull request, so failing the check reported an outage of an unrelated service as a problem with the change under test.

LogCluster.select now tells the two failure kinds apart instead of returning None for both:

  • LogClusterQueryError - the cluster answered by rejecting the query (4xx: bad SQL, a missing table, denied access). A defect no retry can fix; it must stay visible.
  • LogClusterUnavailable - the cluster never answered (5xx on every retry, every POST raising, or the endpoint never becoming ready, including a failed AWS SSM lookup of the endpoint or the password).

On LogClusterUnavailable the job completes green with an explanatory info line, and refreshes its pinned pull request comment so that an earlier commit's comparison is not left standing as if it described the head. Green as OK rather than SKIPPED: both are green, but the report greys out a skipped job and drops the link to its own report, and for an outage the job log is the whole diagnostic.

Everything else is unchanged and still fails the job: a rejected query, a missing master baseline, an unresolved build run.

Verified with a throwaway pytest suite (not committed, since ci/tests was removed from the repository) covering both select classifications - 5xx, transport exception, never-ready endpoint, failed secret lookup, 4xx, success - and main end to end: an outage at the first query and at the baseline lookup exits 0 with an OK result, while a rejected query and a missing baseline still raise.

Changelog category (leave one):

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

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

…nswer

The check's only data source is the CI logs cluster, which is shared by the
whole CI fleet: it has minutes-long windows where every query fails with
Code 241 (server-wide memory pressure), plus the usual endpoint, credential
and transport outages. A read that never got an answer measured nothing about
the pull request, so failing the check reported an outage of an unrelated
service as a problem with the change under test.

`LogCluster.select` now tells the two failure kinds apart instead of returning
`None` for both: `LogClusterQueryError` when the cluster answered by rejecting
the query (4xx - bad SQL, a missing table, denied access) and
`LogClusterUnavailable` when it never answered it (5xx on every retry, every
POST raising, or the endpoint never becoming ready, including a failed AWS SSM
lookup of the endpoint or the password).

On `LogClusterUnavailable` the job now completes green with an explanatory
info line, and refreshes its pinned pull request comment so that an earlier
commit's comparison is not left standing as if it described the head. Every
other path is unchanged and still fails the job: a rejected query, a missing
master baseline, an unresolved build run.
@clickhouse-gh

clickhouse-gh Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0c06b18]

Summary: ✅


AI Review

Summary

This PR makes Build profile diff complete green when the CI logs cluster is unavailable by distinguishing transport/shared-cluster outages from query rejections and by refreshing the pinned PR comment on that green path. The earlier status >= 500 misclassification is fixed, but the transient exception-code whitelist is still broad enough to hide some real query regressions, so this is not ready to merge yet.

Findings

❌ Blockers

  • [ci/jobs/scripts/log_cluster.py:347] report_cluster_unavailable promises the green path only when the cluster never answered, but _classify also treats 159 (TIMEOUT_EXCEEDED) and 209 (SOCKET_TIMEOUT) as LogClusterUnavailable. Those are still ClickHouse verdicts on this specific query, so a broken reporting SELECT that becomes too slow or hits a socket timeout would now surface as LogClusterUnavailable, land in main's green handler, and hide the defect behind an OK check. Suggested fix: keep the green path to exception codes that unambiguously prove shared-cluster overload, or treat 159/209 as LogClusterQueryError.
Final Verdict

❌ Changes requested. The broad transient-code whitelist can still convert real reporting-query failures into a green check.

LLVM Coverage Report

⚠️ No coverage measurement for commit 0c06b18: 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 19, 2026
Comment thread ci/jobs/scripts/log_cluster.py Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 19, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 0c06b1809 with master 2ee0ab46f (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 295f03a88; 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

6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator

is_ready() classification, as asked on #120288. Here is the change.

The last raise in select is reached only when all 8 attempts gave up before their POST, i.e. is_ready() was false for every one of them across the 180 s of backoff the loop sleeps; any attempt that passes the readiness gate sets post_attempted before its POST. So that leg is already the persistent case, and turning it into a hard failure needs no new state, only a class main() does not catch:

class LogClusterNotReady(LogClusterError):
    """The endpoint never became ready.

    A readiness probe that never answers is indistinguishable from a rotated
    password or a deleted SSM parameter, and completing green on that would
    blank the check fleet-wide for as long as the condition lasts.
    """
        # Every attempt gave up before its POST: `is_ready()` was false for all
        # of them.
        raise LogClusterNotReady("the endpoint never became ready")

main() catches LogClusterUnavailable only, so a sibling of LogClusterError reaches the generic handler, refreshes the pinned comment and fails the job. build_profile_diff_job.py needs no change.

One cause that classification pulls in with it, worth naming because it is the live incident: is_ready() returns a bare False for five different reasons, and a transport timeout on its own 3 s SELECT 1 is one of them, so an outage deep enough that even the probe stops answering for a whole window would go red as well. The current one does not reach that. The endpoint keeps answering the probe and times out only on the heavy reads: every failing job log I sampled, including the 13:18Z burst today, has zero LogCluster not ready lines and zero select failed with code lines, only ReadTimeout. If you want only the three causes you named to be red, having is_ready() return its reason instead of a bool is about five lines. Your call.

I am not pushing to your branch: take the patch here, or say so and I will send it as a follow-up PR as soon as this one lands.

One ask from @ azat's review of #118708 that closes with it: an error the server reports after committing a 200, his example was MEMORY_LIMIT_EXCEEDED, should count as transient rather than as a rejection. In my local probe of that path the job's own client, requests, saw status=500 for it in 6 runs of 6, so the >= 500 leg here already covers it.

Merged via the queue into master with commit 1a75e54 Sep 21, 2026
176 checks passed
@alexey-milovidov
alexey-milovidov deleted the ci-build-profile-diff-green-on-cluster-outage branch September 21, 2026 16:14
@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
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Your reading of the second finding is adopted, in a follow-up rather than here: this pull request merged as 1a75e54f4c38 while the finding was still open, so the change is #121393.

TRANSIENT_EXCEPTION_CODES is now {202, 241}. The structural argument is the one you gave: _classify is reached from select only, so 159 and 209 did nothing for the probe's constant SELECT 1 and everything for the reporting SELECTs, where a query that regressed into a server-side timeout was retried eight times and then handed to main as an outage. 202 and 241 stay because both are verdicts about the cluster's own load, and both are observed rather than inferred.

I kept your "free either way" framing in the commit message: whether that cluster's readonly profile can produce a 159 on these reads is not measurable without the CI secrets, and removing the codes is right under both answers.

Verified with a throwaway harness (not committed): 159 and 209 raise LogClusterQueryError after exactly one POST, 202/241 exhaust the eight retries as LogClusterUnavailable, a headerless 502/503 is LogClusterUnavailable, a non-numeric header value falls closed, and 164, 158, 62, 60 are unchanged.

is_ready stays a bool, as you said you had no objection to.

clickgapai pushed a commit to clickgapai/ClickHouse that referenced this pull request Sep 21, 2026
`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 ClickHouse#121048,
addressing the review finding left unresolved there.

Related: ClickHouse#121048
Related: ClickHouse#118708

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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]>
@alexey-milovidov alexey-milovidov mentioned this pull request Sep 24, 2026
1 task done
qoega pushed a commit to qoega/ClickHouse that referenced this pull request Nov 19, 2026
… logs cluster outage

When the read-only sub-service of the CI logs cluster stops answering,
every `SELECT 1` readiness probe of `LogCluster.select` raises
`requests.exceptions.ReadTimeout`. `is_ready` turned that into a bare
False without a `probe_error`, so `select` raised `LogClusterNotReady`,
which `build_profile_diff_job.main` does not catch, and the check went
red on unrelated PRs (8 of them on 2026-11-06 between 00:00Z and 02:52Z,
e.g. job 127646247697 of ClickHouse#129611). The same outage hitting a POST already
ends `LogClusterUnavailable` (ClickHouse#121048), and so does a probe the server
rejects with 241 (ClickHouse#128067).

A probe that raises `ReadTimeout` now records `LogClusterUnavailable` in
`probe_error`, and the tail added by ClickHouse#128067 reports the read green as
"the endpoint never became ready: the readiness probe timed out: ...".
The last probe decides, as there.

A `ReadTimeout` (requests 2.33.0, the CI pin) is raised only after the
name resolved and a server accepted the connection: a stalled TLS
handshake or a stalled answer. Connection refused, an unresolvable name,
no SYN-ACK and a certificate mismatch raise `ConnectionError`
(`ConnectTimeout` and `SSLError` are subclasses), and the server itself
rejects a rotated password with 516. All of those, a missing secret and
a gateway answer still end `LogClusterNotReady`, as ruled on ClickHouse#120288.

This is the `SELECT 1`-timeout leg left open on ClickHouse#121048. Validated with
a throwaway harness against master (real sockets, mocked transport and
`main()` end to end); only the probe-timeout cases change. No test is
committed for the CI scripts (ClickHouse#119766).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue / pr blocks a new release comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). 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