Skip to content

Refresh the Build profile diff comment when the first cluster read fails - #118685

Merged
Felixoid merged 2 commits into
ClickHouse:masterfrom
groeneai:build-profile-diff-refresh-comment-on-first-read-failure
Sep 8, 2026
Merged

Felixoid merged 2 commits into
ClickHouse:masterfrom
groeneai:build-profile-diff-refresh-comment-on-first-read-failure

Conversation

@groeneai

@groeneai groeneai commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #118618

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

The Build profile diff check no longer leaves an earlier commit's comparison pinned to a pull request when its first CI logs cluster read fails.

Description

Build profile diff keeps one tagged comment pinned to a pull request rather than to a commit, so every exit path has to refresh it. 00c5a988268ab37 established that and wrapped the comparison in run_comparison plus a try that replaces the comment with a current-sha "comparison failed" body. Two statements were left outside that guard: db = Db() and the has_pr_data pre-flight, the job's first cluster read.

Cluster reads are fail-closed (Db.query raises once LogCluster.select gives up), so a failure on that first read killed the job before the guard was entered. The job went red and the previous commit's comparison stayed pinned, presenting an older revision as the current one. I measured 15 pull requests in that state within 36 hours; #117054 pinned a comparison of ebc5047ab while its head was 71326cc9.

This moves the cluster handle and the pre-flight inside the existing try: run_comparison runs the pre-flight first and returns None for "the PR side has no data", and main keys the unchanged no-data branch on that result. The guard becomes structural, so another pre-flight cannot re-open the hole.

Nothing becomes green: the job still exits non-zero and reddens on every failure path, and only the pinned comment changes. The grant half of the failure that exposed this landed separately in #118618, which touches only the import and Db.__init__ here.

Validated with an uncommitted seven-arm harness over main()'s exits, run both ways: the two affected exits go from no refresh to a current-sha refresh, the other five are unchanged. No file is added under ci/tests/: 3a69545dc040228 removed this job's own test in the CI-script unit-test sweep and set the rule in .claude/CLAUDE.md that a throwaway validation script need not be committed.

Provenance: found while building the CI finish ledgers for #116933, #118084 and #118588; no related open issue.


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

Version info

  • Merged into: 26.9.1.945 (included in 26.9 and later)

The `build-profile-diff` comment is pinned to the pull request, not to a
commit, so every exit path of the job has to refresh it. 00c5a98
established that invariant and wrapped the comparison in `run_comparison`
plus a `try` whose `except` replaces the tagged comment with a current-sha
"comparison failed" body. It enumerated `get_master_shas`, `find_baseline`,
`resolve_run`, `extend_master_shas` and "every cluster read" as the readers
that fail closed, and all of those live inside `run_comparison`. Two
statements were left above the guard: `db = Db()` and the `has_pr_data`
pre-flight, which is the job's first cluster read.

Cluster reads are fail-closed. `LogCluster.select` returns None once it gives
up (it retries >= 500 and connection errors, then breaks out on a 4xx) and
`Db.query` turns that into a RuntimeError, so a failure on that first read
left `main` unhandled: the job exited non-zero and `update_comment` was never
reached, so an earlier commit's comparison stayed pinned and presented a
previous revision, possibly one the head reverted, as the current comparison.
Measured on master, 15 pull requests were in that state within 36 hours;
ClickHouse#117054 pinned a comparison of ebc5047 while its head was 71326cc.

`run_comparison` now performs the pre-flight as its first statement and
returns None for "the PR side has no build profile data", `db = Db()` moves
inside the `try`, and the unchanged no-data branch is keyed on that None
result. The cluster handle and every cluster read are then inside the guard,
so another pre-flight cannot re-open the hole. The job still exits non-zero
and still reddens on every failure path; only the pinned comment changes.
Deliberately not done: degrading a refused read to "no baseline data" or to
Result.Status.OK, which would convert a visible outage into a green check.

Two clauses of the `except` block's comment are updated rather than moved
verbatim, because the move falsified them: the no-data path it referred to as
"as above" is now below it, and its list of what the guard covers did not
mention the cluster handle.

Validated with a seven-arm harness over the exits of main(), one arm per exit,
with the cluster, the GitHub call and praktika's result writing stubbed. Run
against the unmodified file, the two affected exits (a raising `Db()` and a
raising pre-flight) record no `update_comment` call at all while the other
five pass; with this change all seven pass. No file is added under ci/tests/:
3a69545 deleted this job's own
test_a_failed_comparison_replaces_the_stale_comment along with the rest of the
CI-script unit tests, and set the rule in .claude/CLAUDE.md that a throwaway
script used to test a CI change does not need to be committed because there
are no automated CI tests.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Sep 8, 2026
@groeneai

groeneai commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

An independent model reviewed this diff cold twice before publication, no findings either time, and my
own review raised nothing in the code. Three things worth recording:

  • ⚠️ The invariant this restores is @ alexey-milovidov's own, stated in 00c5a988268ab37: "every exit
    path has to refresh it". Every reader that commit enumerated lives inside run_comparison;
    has_pr_data and Db() were the two statements left above the guard it created.
  • 💡 Info() and the pr_number / pr_sha reads stay above the guard by necessity, not as a
    residual: the failure body interpolates pr_sha, and GH.post_updateable_comment returns False
    without a valid PR number (ci/praktika/gh.py:1009-1014), so no refresh is expressible earlier.
  • 💡 ci/jobs/scripts/job_hooks/build_profile_hook.py and log_cluster.py are untouched here, and
    ci: switch user for build profile diff #118618's hunks in this file are the import and Db.__init__, so the two changes are disjoint.

No committed test, deliberately: 3a69545dc040228 deleted this job's own
test_a_failed_comparison_replaces_the_stale_comment and set the rule in .claude/CLAUDE.md that a
throwaway script used to test a CI change need not be committed. Validation is an uncommitted
seven-arm harness over the exits of main(), run in both directions.

@clickhouse-gh

clickhouse-gh Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2b03b35]

Summary: ✅


AI Review

Summary

This PR moves Db() construction and the has_pr_data pre-flight under the existing failure-handling path so the Build profile diff PR comment is refreshed even when the first CI logs read fails. I did not find a remaining contract violation in the touched code: the no-data path is preserved, only_update=True still prevents creating a new failure or no-data comment when the PR never had one, and the rest of the job behavior is unchanged.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 8, 2026
@groeneai

groeneai commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @Felixoid, could you review this? Build profile diff pins one tagged comment to the pull request rather than to a commit, and db = Db() plus the has_pr_data pre-flight sat outside the try that refreshes it, so a failing first cluster read left an earlier commit's comparison pinned while the job went red; this moves both inside the existing guard and makes no failure path green.

@clickhouse-gh

clickhouse-gh Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 2b03b359a with master bd4f0881a (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 55c256363; 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

@Felixoid Felixoid self-assigned this Sep 8, 2026
@Felixoid
Felixoid added this pull request to the merge queue Sep 8, 2026
Merged via the queue into ClickHouse:master with commit abe8546 Sep 8, 2026
174 checks passed
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-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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