Repository navigation
Refresh the Build profile diff comment when the first cluster read fails - #118685
Conversation
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]>
Internal second-model reviewAn independent model reviewed this diff cold twice before publication, no findings either time, and my
No committed test, deliberately: |
|
Workflow [PR], commit [2b03b35] Summary: ✅ AI ReviewSummaryThis PR moves Final VerdictStatus: ✅ Approve |
|
cc @Felixoid, could you review this? |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
Related: #118618
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
Build profile diffcheck no longer leaves an earlier commit's comparison pinned to a pull request when its first CI logs cluster read fails.Description
Build profile diffkeeps one tagged comment pinned to a pull request rather than to a commit, so every exit path has to refresh it.00c5a988268ab37established that and wrapped the comparison inrun_comparisonplus atrythat replaces the comment with a current-sha "comparison failed" body. Two statements were left outside that guard:db = Db()and thehas_pr_datapre-flight, the job's first cluster read.Cluster reads are fail-closed (
Db.queryraises onceLogCluster.selectgives 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 ofebc5047abwhile its head was71326cc9.This moves the cluster handle and the pre-flight inside the existing
try:run_comparisonruns the pre-flight first and returnsNonefor "the PR side has no data", andmainkeys 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 underci/tests/:3a69545dc040228removed this job's own test in the CI-script unit-test sweep and set the rule in.claude/CLAUDE.mdthat 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
26.9.1.945(included in26.9and later)