Skip to content

Make perf CIDB metrics/history inserts best-effort - #108712

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-cidb-insert-best-effort
Jun 28, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-cidb-insert-best-effort

Conversation

@groeneai

@groeneai groeneai commented Jun 27, 2026 •

Copy link
Copy Markdown
Collaborator

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

The Performance Comparison job opened insert_raw_query_metrics_data() and insert_historical_data() with a bare assert cidb.is_ready(). A transient LogCluster (play.clickhouse.com) SELECT 1 timeout (3s) therefore raised AssertionError and failed the whole perf job with exit code 1, even though metrics insertion is a reporting side-effect and the perf verdict itself was green.

Observed on PR #107236, Performance Comparison (arm_release, master_head) shards 2/6 and 5/6:

Fail [Performance Comparison (arm_release, master_head, 2/6)]
  | 2 slower, 4 unstable
  Fail [Insert raw query metrics data]
    | File ".../ci/jobs/performance_tests.py", line 1364, in insert_raw_query_metrics_data
    |     assert cidb.is_ready()
    | AssertionError
    | ERROR: LogCluster connection failed ... play.clickhouse.com ... Read timed out. (read timeout=3)
ERROR: Run failed with exit code [1]

In the same run, sibling shards with comparable or worse perf annotations passed because their metrics insert succeeded:

Shard Perf summary Metrics insert Job status
1/6 1 slower, 1 unstable Inserted 5080784 rows OK
3/6 7 unstable Inserted 5227872 rows OK
2/6 2 slower, 4 unstable assert cidb.is_ready() -> AssertionError FAIL
5/6 1 too long, 2 slower, 2 unstable assert cidb.is_ready() -> AssertionError FAIL

Shard 3/6 had 7 unstable and still passed, confirming "slower/unstable/too long" are informational; the perf gate only fails on > 10 slower queries (SLOWER_QUERIES_FAIL_THRESHOLD). The job's exit-1 came solely from the metrics-insert assert.

These functions already treat a failed insert as non-fatal (log and return True), and CIDBCluster.do_insert_query() already calls is_ready() internally and returns False gracefully, so the top-level assert was both redundant and harmful. This change replaces it with the same skip-and-warn guard already used by insert_report_aggregates() and prepare_historical_data() in this file:

if not cidb.is_ready():
    print("WARNING: CIDB not ready - skipping ...")
    return True

Adds a regression test in ci/tests/test_perf_slow_gate.py asserting that no perf CIDB-insert path re-introduces a bare assert cidb.is_ready() and that every is_ready() call site in the job is guarded.

Failure report (shard 2/6): https://s3.amazonaws.com/clickhouse-test-reports/PRs/107236/15cd4c31d28e40d015ba4830937a5a8df2c9073a/performance_comparison_arm_release_master_head_2_6/report.html

Version info

  • Merged into: 26.7.1.183 (included in 26.7 and later)

The Performance Comparison job opened insert_raw_query_metrics_data() and
insert_historical_data() with a bare assert cidb.is_ready(). A transient
LogCluster (play.clickhouse.com) timeout therefore raised AssertionError and
failed the whole perf job with exit code 1, even though metrics insertion is a
reporting side-effect and the perf verdict was green.

These functions already treat a failed insert as non-fatal (log and return
True), and CIDBCluster.do_insert_query() already calls is_ready() internally
and returns False gracefully, so the top-level assert was both redundant and
harmful. Replace it with the same skip-and-warn guard that
insert_report_aggregates() and prepare_historical_data() already use.

Add a regression test asserting no perf CIDB-insert path re-introduces a bare
assert cidb.is_ready() and that every is_ready() call site is guarded.

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

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The failing path is assert cidb.is_ready() (performance_tests.py:1364/1426). When play.clickhouse.com SELECT 1 times out (3s), is_ready() returns False, the assert raises AssertionError, the sub-result FAILs, and the job exits 1. Confirmed in both failing shards' job.log; the regression test reproduces the guard contract deterministically (fails without fix, passes with fix).
b Root cause explained? Yes. Metrics insertion is a reporting side-effect, not the perf verdict. A transient LogCluster (play.clickhouse.com) read timeout makes is_ready() return False -> bare assert raises -> whole perf job exits 1. The perf gate itself was green (status set OK unless >10 slower queries; failing shards had only 2 slower). Control: sibling shard 3/6 had 7 unstable and PASSED because its insert succeeded.
c Fix matches root cause? Yes. Replaces the harmful assert cidb.is_ready() with the graceful skip-and-warn guard (if not cidb.is_ready(): warn; return True), so a transient timeout no longer aborts the job. It does not touch perf thresholds, so a real regression still fails the job.
d Test intent preserved / new tests added? Yes. No existing test weakened. Added test_cidb_inserts_are_best_effort_not_asserted to ci/tests/test_perf_slow_gate.py asserting no perf CIDB-insert path contains a bare assert cidb.is_ready() and that all four is_ready() call sites are guarded.
e Both directions demonstrated? Yes. With fix: test_perf_slow_gate.py passes (0 asserts, 4 guards). Reverting only the source edit (git stash): the new test FAILs with the exact AssertionError, proving it catches the regression.
f Fix is general across code paths? Yes. Both bare-assert sites (insert_raw_query_metrics_data, insert_historical_data) are fixed; the two already-graceful sites (prepare_historical_data, insert_report_aggregates) are unchanged. All four is_ready() call sites in the job now use the same guard. Not a symptom patch: the assert was redundant (do_insert_query already calls is_ready() and returns False gracefully) and the body already treats insert failure as non-fatal.
g Fix generalizes across inputs? N/A (CI script reliability fix, not a code-path-dependent product bug). The guard is independent of perf data, datatypes, or settings.
h Backward compatible? N/A (CI script only; no user-facing setting, format, or behavior change).
i Invariants and contracts preserved? Yes. The functions' contract is "best-effort reporting, return True"; the fix makes the timeout path honor that contract instead of violating it via an assert. The perf-verdict path (too_many_slow, report-html status) is untouched.

Session id: cron:clickhouse-worker-slot-0:20260627-202600

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv @leshikus — could you review this small CI reliability fix? It makes the perf job's CIDB metrics/history inserts best-effort: a transient play.clickhouse.com timeout in is_ready() was raising AssertionError and failing the whole Performance Comparison job (exit 1), even though metrics insertion is just reporting and the perf verdict was green. The fix uses the same skip-and-warn guard already present in insert_report_aggregates() / prepare_historical_data().

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 27, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [09b3c22]

Summary: ✅


AI Review

Summary

This PR makes the Performance Comparison CIDB metrics and historical-data insert steps best-effort when CIDBCluster.is_ready reports the cluster unavailable, matching the existing non-fatal handling used by the other reporting uploads. I found no correctness or reliability issue in the current diff.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 27, 2026
@alexey-milovidov alexey-milovidov self-assigned this Jun 28, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 28, 2026
Merged via the queue into ClickHouse:master with commit d5ca1f1 Jun 28, 2026
169 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 Jun 28, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-insert-best-effort

Make perf CIDB metrics/history inserts best-effort
pull Bot pushed a commit to Haofei/ClickHouse that referenced this pull request Sep 26, 2026
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]>
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 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