Skip to content

Perf CI: retry the CIDB uploads the dashboard gate judges from, and fail closed when one is missing - #122369

Merged
fm4v merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-ci-retry-dashboard-input-uploads
Sep 26, 2026
Merged

fm4v merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-ci-retry-dashboard-input-uploads

Conversation

@groeneai

@groeneai groeneai commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #113589 (comment)
Related: #120927
Related: #121847

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):

Not required: CI-only change.

Description

Performance Comparison (*, master_head, N/6) shards fail with performance dashboard verdict unavailable: dashboard did not serve this shard within 600s when nothing regressed. Failing job: https://github.com/ClickHouse/ClickHouse/actions/runs/35752871102/job/106898413731 (report). Its three Insert ... steps print Connection refused and CIDB not ready - skipping in 0.1-0.2 s, then Check Results fails after 614 s. On master: amd 3/6 @ f90a58a8. On 2026-09-25 a CIDB overload failed 70 shards on 21 PRs and master the same way. In the same run of #122252, amd_release 1/6 uploaded and got its verdict in 2 s, while arm_release 6/6 skipped the uploads and failed at 612 s.

Each upload step probed CIDB once and skipped on failure, and a failed INSERT got at most two retries 1 s apart. Since #120927 the dashboard computes the gate's verdict from these tables, so the gate waited 600 s for rows that were never sent.

One helper now runs all four INSERT sites. In master_head mode the three tables the verdict is computed from are retried every 60 s within one 600 s budget, shared with the gate's wait, and a 4xx other than 408 or 429 (a broken query, schema or credential) is not retried. UI tables get a single attempt. Every attempt carries an insert_deduplication_token, so an INSERT that committed after the client timed out is not doubled. If one of the three is still missing, the gate fails at once and names it with the error. A shard without a verdict still fails, and release_base is unchanged apart from the token and a 408 or 429 now being retried like a 5xx.

An outage that outlasts the last retry still fails the shard, now with the cause named. PR re-runs share the dashboard run id with earlier attempts, which this change does not touch.

Local validation

The master build served as a local ReplicatedMergeTree CIDB behind a fault-injecting proxy, with the real functions and the payloads of #122252 amd_release 1/6:

fault result
none, 2,008,404 rows sent twice (3 blocks) 2,008,404 rows. Without the token: 4,016,808
INSERT committed, response held past the client timeout one retry, 2,008,404 rows, 3 blocks deduplicated
refused 5 s; Code 202 on the probe or the INSERT the next attempt after recovery lands all rows
refused 5 s, master code 0 of 112 rows, then the gate waits and blames the dashboard
always refused, 10 s budget stops at 8 s, when no further 2 s pause fits, and the next input still gets one attempt. The gate fails at once naming the tables and the last error, with 0 dashboard calls
INSERT into a missing table (HTTP 404) one attempt. The next input lands all rows, and the gate quotes the server's UNKNOWN_TABLE error
UI table, or release_base one call, no retry loop
dashboard 404, nothing missing fails at the shared deadline, sleep capped

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

Version info

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

The REPORT-stage uploads of a performance shard probed CIDB once and
skipped the whole step when that probe failed ("CIDB not ready -
skipping"), and a failed INSERT was not retried either. That was fine
while the tables were informational (ClickHouse#108712), but since ClickHouse#120927 the
performance dashboard computes the master_head verdict from exactly
these tables. A CIDB refusal of seconds or an overload of minutes
therefore dropped the shard's rows, and perf_dashboard_gate then waited
600 s for data that was never sent and failed the shard with "dashboard
did not serve this shard within 600s", blaming the dashboard.

Measured: ClickHouse#113589 arm 6/6 skipped all three uploads on "Connection
refused" and failed after 614 s. On 2026-09-25 a CIDB overload
(TOO_MANY_SIMULTANEOUS_QUERIES, read timeouts) failed 70 shards on 21
PRs and master. In 74 of the 76 occurrences since 2026-09-22 that are
not the time zone shape fixed by ClickHouse#121847, an upload was skipped or
failed. The same run of ClickHouse#122252 is the control: amd 1/6 uploaded and
got its verdict in 2 s, while arm 6/6 skipped the uploads and failed.

Now one helper runs all four INSERT sites. In master_head mode the
three tables the verdict is computed from (query_metric_runs_v1,
query_metrics_v2, perf_test_times_v1) are retried every 60 s until one
600 s deadline, which is taken when the uploads start and shared with
the gate's wait. The other tables keep a single attempt, and nothing is
sent after the deadline. Every attempt carries the same
insert_deduplication_token, because some INSERTs that timed out on the
client had committed on the server. If one of the three inputs was not
uploaded, the gate fails at once and names it instead of polling the
dashboard. A shard without a verdict still fails, as ClickHouse#120927 designed,
and release_base keeps its single call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Sep 26, 2026
@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; 2 findings), plus my own review.

# Sev Finding Verdict Evidence / action
1 ⚠️ The shared 600 s deadline does not cap in-flight requests (60 s dashboard polls, the final /confidence call, the 3 s CIDB probe) DISAGREE Request timeouts are unchanged from master, and the worst case falls: master ran the uploads with no deadline, then a fresh 600 s gate window; here both share one 600 s. Capping /confidence or the last poll to the time left would turn a dashboard that is ready at the edge into a false "verdict unavailable" red.
2 ⚠️ No reproducible evidence for the retry, deduplication and fail-closed paths DISAGREE A local fault-injection harness ran the committed functions against a ReplicatedMergeTree CIDB (26.10): 20/20 checks on attempts, rows, elapsed time and dashboard calls, summarized in the description. No ci/tests/ file, since nothing runs that directory.
3 💡 A deterministic 4xx on an input table is retried until the deadline; the missing-input message also covers a local TSV build failure; insert_into_cidb's docstring means that no attempt starts after the deadline noted none

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

Session id: cron:clickhouse-review-slot-8:20260926-020400

@clickhouse-gh

clickhouse-gh Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [86e439a]


AI Review

Summary

This PR retries the CIDB uploads that the performance dashboard gate depends on and fails closed when one of those inputs is missing. The direction is right, and the earlier 4xx/error-reporting gap is fixed, but the shared 600-second budget is still applied incorrectly in two places: dashboard-input retries stop a full minute early, and unrelated UI-only uploads can still consume the gate's remaining time. Those gaps can still produce false-red perf shards after a recoverable CIDB outage.

Findings

⚠️ Majors

  • [ci/jobs/performance_tests.py:1066] The retry loop stops as soon as there is not enough time for another full CIDB_UPLOAD_RETRY_INTERVAL_SEC sleep, not when there is not enough time for another upload attempt. With fast Connection refused failures, this exits around T+542s and leaves almost a minute of budget unused, so an outage that clears before the documented 600-second window can still leave query_metric_runs_v1 marked missing.
    Suggested fix: compute the cutoff from the time needed for one more upload round instead of from the fixed 60-second backoff interval.
  • [ci/jobs/performance_tests.py:2747] The shared upload_deadline is being spent on every REPORT_UPLOADS table and the later flamegraph upload, even though the dashboard verdict only depends on query_metric_runs_v1, query_metrics_v2, and perf_test_times_v1. If those required tables land near the deadline, a slow best-effort UI upload can exhaust the remaining budget before perf_dashboard_gate runs and still fail the shard red.
    Suggested fix: keep the shared deadline only on the three dashboard inputs and run the informational uploads outside that budget or after the dashboard gate.
Final Verdict

Request changes. The PR still leaves false-red paths in the exact deadline handoff it is trying to fix.

Comment thread ci/jobs/performance_tests.py Resolved
Comment thread ci/jobs/performance_tests.py Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 26, 2026
… missing

insert_into_cidb retried every failed INSERT of a dashboard input until
the 600 s deadline, including a 4xx from CIDB (a broken query or schema:
UNKNOWN_TABLE, TYPE_MISMATCH, a parse error). Such an upload spent the
whole budget, the inputs uploaded after it got no attempt, and the gate
reported "not uploaded to CIDB within 600s" without the server's error,
which points triage at CIDB instead of the query. The same message was
used for local failures (a TSV that could not be prepared, a missing
source file), and an upload step that raised was not recorded at all, so
the gate waited for the dashboard and blamed it.

CIDBCluster.is_ready and do_insert_query now record why the probe or the
INSERT failed and whether CIDB answered it with a 4xx other than 408 or
429 (timeout, throttling), which are retried like a 5xx. insert_into_cidb stops at once on such a
rejection and returns the reason. Each dashboard input is recorded as
missing when its upload step starts and is cleared only when the upload
succeeds, so the gate names every missing input with its reason, an
exception included. A failing input also no longer sleeps out the rest
of the budget when no further attempt fits, so the next input still gets
that time.

Checked against a local ReplicatedMergeTree CIDB with real payloads: an
INSERT into a missing table now fails after one attempt with the
server's UNKNOWN_TABLE error while the next input lands all rows. On the
previous head the same fault took 6 attempts over the whole budget and
the next input got none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Sep 26, 2026
return f"rejected: {error}"
if table not in DASHBOARD_INPUT_TABLES:
return error
if deadline - time.monotonic() <= CIDB_UPLOAD_RETRY_INTERVAL_SEC:

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.

The new cutoff is still 60 seconds early. This branch fires whenever there isn't room for another full CIDB_UPLOAD_RETRY_INTERVAL_SEC sleep, not when there isn't room for another upload attempt. With the fast Connection refused failures this PR is targeting, the raw-metrics loop reaches this path at about T+542s, leaves roughly 58 seconds on the shared deadline, and marks query_metric_runs_v1 missing without ever trying again. That means an outage that clears before the documented 600-second budget can still fail closed simply because the final retry window is discarded.

Can we base this stop condition on the time needed for another upload round instead of on whether a whole 60-second pause fits?

info=info,
reference_sha=reference_sha,
compare_against_release=compare_against_release,
deadline=upload_deadline,

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.

upload_deadline is supposed to cover the three inputs the dashboard verdict depends on and the later dashboard wait, but this call passes the same deadline to every REPORT_UPLOADS table, and the same block later does it again for insert_flamegraph_stacks. Once query_metric_runs_v1, query_metrics_v2, and perf_test_times_v1 are uploaded, the remaining budget can still be burned on perf_test_perf_changes_v1 / flamegraph uploads that are explicitly UI-only.

Concrete trace: if the required inputs finally land near T+545s, a single slow best-effort upload here can consume the last ~20 seconds before perf_dashboard_gate even starts, and the shard still fails with dashboard did not serve this shard within 600s although the dashboard already had everything it needed. These informational uploads need to run outside the shared deadline or after the gate.

@fm4v

fm4v commented Sep 26, 2026

Copy link
Copy Markdown
Member

@groeneai check reviews

@fm4v fm4v self-assigned this Sep 26, 2026
@fm4v
fm4v enabled auto-merge September 26, 2026 07:06
@fm4v
fm4v added this pull request to the merge queue Sep 26, 2026
Merged via the queue into ClickHouse:master with commit ee0c20b Sep 26, 2026
155 of 157 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 26, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

I checked the two open threads from the second bot review.

  • Retry cutoff: correct. After a fast failure the loop gives up once a full 60 s pause no longer fits, so the last attempt is at about T+540 and an outage that clears in the final minute still fails the shard. Pausing only until one INSERT timeout (20 s) before the deadline keeps one more attempt at about T+580. I'll send that as a small follow-up PR and link it here.
  • UI uploads sharing the deadline: I don't think it holds. Once the inputs are uploaded, the gate polls the dashboard at least once before it checks the deadline, so a slow UI upload only delays that poll, and in the described trace it still finds the shard. Moving the UI uploads after the gate would not make its last poll any later, so I'd leave the order as is.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Follow-up for the retry cutoff: #122421

pull Bot pushed a commit to Dream-hu/ClickHouse that referenced this pull request Sep 27, 2026
…re the deadline

insert_into_cidb stopped retrying a failed upload of a dashboard input
as soon as a whole 60 s pause no longer fit before the 600 s deadline it
shares with perf_dashboard_gate, not when another attempt no longer fit.
With fast refusals (Connection refused) the attempts of
query_metric_runs_v1 land at about T+0, T+60, ..., T+540. After the
T+540 failure about 59 s were left, the loop gave up, and an outage that
ended after about T+541 still failed the shard with "the shard's results
were not uploaded to CIDB: query_metric_runs_v1 (the 600s budget was
spent, ...)".

The pause is now at most CIDB_UPLOAD_RETRY_INTERVAL_SEC, and never so
long that less than one CI_DB_INSERT_TIMEOUT_SEC (20 s) is left for the
next attempt; the loop stops only when not even that fits. So the last
attempt can start as late as 20 s before the deadline, with the full
insert timeout, and the WARNING prints the pause actually taken. Pauses
while more than 80 s are left and healthy runs are unchanged. A
permanent outage makes at most one more attempt per input and fails the
shard about 39 s later. When a failure left 60 to 80 s, the old code
slept 60 s and made its last attempt with a truncated timeout; that
attempt is now made earlier, with the full timeout.

Found by the automated review of ClickHouse#122369.

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

can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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.

3 participants