Skip to content

Judge a master_head performance shard by its own report when CIDB or the dashboard does not answer - #125734

Merged
egor-click merged 5 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-dashboard-unavailable-fallback
Oct 15, 2026
Merged

egor-click merged 5 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-dashboard-unavailable-fallback

Conversation

@groeneai

@groeneai groeneai commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #116101
Related: #120927

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

Asked in #116101 (comment).

On #116101 at 3b7362d6, 5 of 12 Performance Comparison (*, master_head, N/6) shards failed although each shard's own comparison found 0 slower queries (amd 1/6, arm 1/6). Their uploads ran during the 2026-10-13 CIDB outage, so the dashboard had no data, and main turns every PerfDashboardError into a failure.

Changes:

  • CIDBCluster.last_unavailable: a transport error, a 5xx without X-ClickHouse-Exception-Code, or code 202 (and 241 for the SELECT 1 probe), classified on that header like LogCluster.
  • The dashboard API raises PerfDashboardUnavailable for transport errors (also an answer cut short), a gateway 502/503/504, a 404 code = NotFound, and the two backend-outage 5xx messages seen so far.
  • Then the shard is judged by its own report: any slower query fails it. The dashboard replaced a "more than 10 slower" rule that passed a single +2225% query (Join reordering: FK->PK heuristic for equi joins without NDV statistics #120176); "more than 0" still catches it. A 4xx, an unknown 5xx, a missing secret or a malformed answer still fails the shard, also when CIDB or the dashboard stops answering after it.
  • /confidence is retried until the deadline; one HTTP 500 from it failed a shard on Unified cardinality estimation across join order, distributed and Cascades planners #124320.
  • insert_historical_data no longer prints its 254k-line TSV twice: on amd 1/6 that took 15 s and the budget ran out right after CIDB came back.

"Too long" tests do not fail a shard: on that commit amd 2/6 passed with 5 too long and amd 3/6 failed with none.

Trade-off while the dashboard is down (14 days of CIDB): 3% of green PR shards had a slower query and would fail; 16% of dashboard-blocked shards had none and would pass.

Validation: a local harness with fake CIDB and dashboard servers, 151 cases on master and on this branch, and 18 code mutations that it catches.


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

Version info

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

groeneai and others added 4 commits October 14, 2026 01:19
…hboard does not answer

In `master_head` mode `main` turned every `PerfDashboardError` into a failure,
and nothing told an outage of CIDB or of the dashboard from a defect of the
job. On ClickHouse#116101 at 3b7362d, 5 of 12 shards failed during the 2026-10-13 CIDB
outage although every shard report found 0 slower queries.

- `CIDBCluster.last_unavailable`: the last failed call met a transport error,
  an answer without `X-ClickHouse-Exception-Code` (not from the server), or
  the server's own-load code 202 (also 241 for the `SELECT 1` probe; an
  INSERT can exceed a memory limit by itself). `last_rejected` and the retry
  decisions are unchanged.
- `insert_into_cidb` tags a budget-spent reason with that, and an upload that
  never started; the gate counts the missing inputs as unavailable only when
  a classified outage spent the budget.
- `dashboard_api_get` raises `PerfDashboardUnavailable` for transport errors,
  a gateway 502/503/504, a 404 with the backend's `code = NotFound`, and the
  measured outage messages `connect: connection refused` and
  `context canceled`. At the deadline the gate raises the class of the last
  reason, so a persistent wrong answer still fails.
- On `PerfDashboardUnavailable` the shard is judged by its own summary: any
  slower query fails it (the gate exists because "more than 10 slower" passed
  a single +2225% query in ClickHouse#120176). An invalid summary still fails.
- `/confidence` is retried until the deadline (a single HTTP 500 failed a
  shard on ClickHouse#124320).
- `insert_historical_data` no longer prints its TSV twice: on amd 1/6 that
  took 15 of the last 17 s of the budget.

Requested in ClickHouse#116101 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- `CIDBCluster._record_http_error`: only a 5xx can mean CIDB did not answer.
  A 408 or 429 without `X-ClickHouse-Exception-Code` comes from a proxy (the
  server sends 408 only with code 159 and never sends 429); it is still
  retried, but no longer turns a shard green.
- `dashboard_list`: `items`, `testTimes` and `slowdowns` of a dashboard answer
  must be lists (the live API returns `[]` when empty). A 200 without them was
  read as "not served yet" (fallback at the deadline), as no slowdowns (green),
  or raised a raw `TypeError` for `null`; it is now a plain
  `PerfDashboardError`.
- `dashboard_api_get`: `http.client.IncompleteRead` (a connection dropped
  mid-body) is a transport failure, and reading the body of an HTTP error is
  guarded, so neither escapes as "Failed to parse the report."; an unreadable
  error body counts as unavailable only for a gateway 502/503/504.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…B error into the fallback

- `insert_into_cidb` and the poll loop of `perf_dashboard_gate` classified a
  failure by its LAST attempt only, so a server verdict (a 500 with code 497,
  an unknown 5xx, a 400, a router 404, a malformed answer) followed by an
  outage reached the fallback. They now keep the first hard error: the reason
  or error is plain (naming the earlier error) unless every failed attempt was
  "did not answer"; a later success still wins.
- The row fields the gate reads are validated before their absence is
  interpreted: an `items` row needs `identity.newSha`/`runId`, a `testTimes`
  row a `title`, and every `slowdowns` row `arch`, `metric`, `test`, an integer
  `queryIndex` and a `confidence.tier`. A row without them was read as "not
  served yet", filtered out, or as the non-blocking tier `unknown`; it is now
  a plain `PerfDashboardError`. Every live row carries them; the tier
  vocabulary stays open.
- `dashboard_api_get`: an HTTP error whose body is cut short is a transport
  failure (`PerfDashboardUnavailable`) whatever the status, as a 200 cut short
  already is; a complete error body keeps its classification.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…west one

`dashboard_run_id` sorts the runs of a sha by `identity.runTime`, so an item
without a non-empty string `newSha`, `runId` or `runTime` is now a malformed
answer instead of letting an older run of the same sha be judged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; r1 3 findings, r2 3 findings, r3 1 finding, r4 none) plus my
own cold reviews (r1 3 nits, r2 2 nits, r3 1 nit, r4 none). Every AGREEd finding is fixed on this head.

# Sev Finding Verdict Evidence / action
1 ⚠️ A headerless HTTP 408/429 from CIDB counted as unavailable (_record_http_error) AGREE, fixed in 90537d83d8ae only a proxy sends them (the server sends 408 only with code 159, never 429); now only a 5xx can be unavailable
2 ⚠️ A dashboard 200 without items / testTimes / slowdowns reached the fallback or an empty verdict AGREE, fixed in 90537d83d8ae the live API always returns these as lists; anything else is a plain error
3 ⚠️ A dashboard body cut mid-read (http.client.IncompleteRead) escaped as Failed to parse the report. AGREE, fixed in 90537d83d8ae counted as transport, like ChunkedEncodingError on the CIDB side
4 ⚠️ A hard CIDB/dashboard error followed by an outage was classified by the last attempt only AGREE, fixed in bfa0ae3eb773 the fallback now needs every failed attempt to be "did not answer"; a success still wins
5 ⚠️ A dashboard row without the field the gate reads (identity, title, arch, confidence.tier, ...) was read as "not served" or non-blocking AGREE, fixed in bfa0ae3eb773 all live rows carry these fields (re-measured on 40 runs: 103 slowdown rows, 123 testTimes rows); anything else is a plain error
6 ⚠️ A non-gateway HTTP error whose body was cut short was a hard error AGREE, fixed in bfa0ae3eb773 an answer cut short is transport whatever its status, as for a 200
7 💡 A well-formed answer that never contains this arch falls back at the deadline DISAGREE indistinguishable from ingestion lag; the fallback is still a verdict, marked judged by this shard's report instead
8 💡 CIDB recovering in the last 2-3 s, with a later input not attempted, still fails the shard DISAGREE measured on amd 1/6: with the TSV prints gone, the remaining inputs are attempted with ~13 s left
9 💡 BadStatusLine / ssl.SSLError from the dashboard still end as Failed to parse the report. DISAGREE same as master and fails closed; no occurrence seen
10 ⚠️ A newest master run without runTime sorted after an older run of the same sha, so the gate could judge the older run AGREE, fixed in 976764512f55 all 42 live /runs items carry it; newSha, runId and runTime must now be non-empty strings
11 💡 A shard judged by its own report adds no workflow warning DISAGREE the check message names the reason and judged by this shard's report instead

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-10:20261014-034900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. A local harness drives the real CIDBCluster, insert_into_cidb and perf_dashboard_gate against a refused port: on master the shard fails, with this change it is judged by its report (0 slower, OK).
b Root cause explained? main turns every PerfDashboardError into a failure, and nothing told "CIDB or the dashboard did not answer" from a defect of the job, so an outage during the uploads failed every shard that uploaded then.
c Fix matches root cause? Yes. Availability is classified where the error happens (CIDBCluster, dashboard_api_get); the fallback is still a verdict (any slower fails); every other error keeps failing the shard.
d Test intent preserved / new tests added? No committed test: this is test infrastructure (#119766). Validated with the local harness below.
e Both directions demonstrated? Yes. 151 cases on master and on this branch, every expectation met on the branch, plus 18 code mutations that the cases catch.
f Fix is general across code paths? Yes. Every failure producer was classified: probe, INSERT, upload reasons, dashboard API, run lookup, poll loop, /confidence. Other CIDBCluster users never read the new flag, and last_rejected is unchanged.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. HTTP 400 to 504 with and without the exception-code header (a headerless 408/429 is never "unavailable"), server codes 62/159/164/202/241/497/516, transport failures including a body cut short or stalled (also of an error answer), a hard error followed by an outage within one retry loop, dashboard answers without their list or with null, rows without the fields the gate reads, bad URLs and secrets, and summaries with 0, 1 and 12 slower, empty or malformed.
h Backward compatible? (maintainer-approved exception only) Yes. No settings. Nothing changes when CIDB and the dashboard answer, and the performance dashboard verdict unavailable: text is kept.
i Invariants and contracts preserved? Yes. A master_head shard is OK only when the dashboard or a valid shard report judged it. last_unavailable is reset on every call, and the retry decisions are unchanged.

Session id: cron:clickhouse-impl-slot-4:20261014-022900

@clickhouse-gh

clickhouse-gh Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7307c73]

Summary: ❌

job_name test_name status info comment
Performance Comparison (arm_release, master_head, 3/6) FAIL Performance dashboard
promql_tags_transform #4 FAIL dashboard IGNORED

AI Review

Summary

PR #125734 lets master_head performance shards use their own report when CIDB or the dashboard is unavailable, while retaining failures for rejected uploads and malformed responses. No actionable findings at head 7307c738f59d07b7fa6fdd4bc973ea7544d04f07; focused local validation passed 216 checks.

Final Verdict

Status: ✅ Approve.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @egor-click @maxknv, could you review this? When CIDB or the dashboard does not answer (transport error, 5xx without X-ClickHouse-Exception-Code, gateway error), a master_head perf shard is now judged by its own report (any slower fails) instead of failing outright; CIDBCluster gets a last_unavailable flag for that. CI also needs the can be tested label, which I cannot add at the moment.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's ok. I see no other way to handle this.

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Oct 14, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 7307c73

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Performance Comparison (arm_release, master_head, 3/6) / promql_tags_transform #4 perf regression from master, not from this diff (it changes CI Python only, so both compared binaries are master code): prometheusQuery(..., 'sum by() (foo)') is about 20% slower (182 to 219 ms) and the dashboard confirmed it as blocking. #121924 showed the same ratio on its own perf runs before it merged at 2026-10-14 23:27Z, and the same query is slower today on 2 other unrelated PRs and on one master run a fix task is created (fixing-PR link to follow here)
Mergeable Check, PR (rollup statuses) derived, they mirror the red job above a fix task is created (same row as above)
Sync - CH Inc sync (private, not actionable by me)

Session id: cron:our-pr-ci-monitor:20261015-023006

@groeneai

Copy link
Copy Markdown
Collaborator Author

Update on the promql_tags_transform #4 row of the ledger above: no fixing PR will follow, the slowdown is the expected cost of #121924.

@egor-click
egor-click added this pull request to the merge queue Oct 15, 2026
Merged via the queue into ClickHouse:master with commit e0d54e8 Oct 15, 2026
175 of 177 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 15, 2026
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 comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). manual approve Manual approve required to run CI 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.

4 participants