Repository navigation
Fix the Upgrade check silently validating against a stale previous release - #115228
alexey-milovidov merged 7 commits into
Conversation
…lease The Upgrade check starts a previous release and then upgrades to the build under test. get_previous_release_tag.py picks that baseline, and it could silently pick one many releases too old. find_previous_release skipped any release below server_version whose metadata did not yet list an uploaded clickhouse-common-static_*.deb, returning (False, None). The caller's unbounded `while not found:` then advanced to the next page. The /releases endpoint is ordered by created_at, not by version, so later pages hold only older releases, and nothing re-checked that the answer was the newest release below the version under test. The only diagnostic on the skip path was a logger.debug under basicConfig(level=INFO), and the resolver still exited 0 with a well-formed tag, so upgrade_runner.sh's `[ $? -ne 0 ]` guard passed. On PR ClickHouse#114376 commit e1cb0de this resolved v25.1.4.53 as the baseline for a 26.8.1.1 build; that 25.1 server then aborted during shutdown on a use-after-free that 2920d33 (ClickHouse#81473) already fixed, so the job reported `Received signal 6` and `Cannot start clickhouse-server` for a reason unrelated to the PR. Two commits earlier the same PR resolved v26.7.3.19 correctly with a byte-identical resolver, and 4 of 47 recent Upgrade-check runs used a wrong baseline. Master and every active release branch already carry the weak_ptr fix, so no C++ change is needed here. Select the baseline by version alone and resolve from the first page or raise. Page 1 holds 100 releases and its newest entry below 26.8.1.1 already equals the maximum over all 700, so the walk was never needed on the healthy path; a page-1 miss means the response was degraded, which is exactly when continuing is wrong. A page cap was rejected because page 2 can supply a stale candidate before any cap fires. Removing the asset filter from selection changes one failure mode deliberately: a partially published release that is genuinely the newest below the build is now selected and fails at the download boundary with `Download script failed`, instead of being skipped in favour of an older one. Validation already fails closed there - download_packages raises for a required prefix absent from the release metadata - so this trades a narrow window for a loud, attributable failure instead of a silent wrong-baseline run. Adds ci/tests/test_get_previous_release_tag.py; the resolver had no tests. Three of the six cases fail on the previous code, returning the exact stale tags observed in CI. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114376&sha=e1cb0dee5e9bd972e9bbbdd8cd8d971ad1e39ee1&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29
…s-release resolver Review round 1 on the previous commit. Two corrections and three additions. Restore the uploaded-package filter as a selection criterion. Dropping it did not contribute to the fix and regressed the release publish window: for the 42.1 hours in the last 6 months where the newest release below master had no uploaded clickhouse-common-static deb, the resolver would select it and die at the download boundary, turning 6063 Upgrade-check runs across 364 PRs from green into a hard failure. The skip now logs at WARNING rather than DEBUG, which is what made the original silent. Enforce the precondition behind reading only page 1 instead of asserting it in a comment. A page shorter than the 100 requested is a degraded response and raises. The invariant holds with large margin: replaying every release event over all 824 releases gives 725 evaluation points and 0 mismatches, the correct baseline's created_at rank is median 2 and max 11 of 100 slots, and a release takes a median 326 days to fall off page 1 against master's ~4-day minor cadence. Guard the empty-releases branch so get_previous_release(None) raises the same diagnostic as the versioned branch instead of a bare IndexError. The pre-existing code did not raise at all on an unresolvable feed, it looped forever fetching pages. Tests go from 6 cases to 11, covering the publish window, a truncated page 1, the cross-page cutoff and the None contract. Two mutation arms confirm the cases that pass on every honest arm still discriminate: reintroducing the page walk reddens the incident case, and an unconditional page-2 union reddens the cutoff case.
Three follow-ups to the resolver fix, none of which changes its behaviour.
Add tests/ci/get_previous_release_tag.py to the CI Tests job cache digest.
The new guards live under ci/tests/, which the digest covers via "./ci", but
their subject does not: Utils.traverse_paths over the job's include_paths
yields 579 files including the test and excluding the resolver, so a change
to the resolver alone leaves the job cache-skippable and the guards never
run against it. Of 59 commits touching tests/ci/ since 2026-05-17, 37 do not
touch ci/ at all. Same one-line shape, and the same reason, as the entry for
build_download_helper.py. A new case asserts the path is in the digest that
praktika actually hashes rather than in the literal list, so it also fires if
the file is renamed or moved out of the digested tree.
Pin the bound behind reading a single page. The code enforces that page 1 was
complete; that only answers the question because a release stays on page 1
much longer than the interval in which a newer one appears. Measured on the
live feed over all 824 releases:
max{v : v < V, v on page 1} == max{v : v < V, v in all releases} 2900/2900
worst created_at rank of the correct baseline 11 of 100
page-1 window span (100 releases) min 76 days, median 321, max 440
minor-version bump gap median 28 days, max observed 73
Two cases cover the shape the real feed has and the boundary where every
eligible entry is more than a minor behind. Both compute the expected answer
from the page fixture instead of hard-coding it, so they state the selection
rule; both redden when the resolver is mutated to take the oldest eligible
release or to return releases[0] unconditionally.
The comment at the raise no longer asserts that conclusion as though it
followed from the created_at ordering, which is what makes version order and
creation order diverge in the first place.
Resolving from the first page only rests on that page holding the newest
release below the version under test. The code enforced that the page was
complete; that alone does not entail it reaches past the answer, and the
step between the two was only argued in a commit message.
Add the missing run-time check: if nothing on the page sorts below the
selected release, the page cannot show that no newer eligible release sits
off it, so raise instead of returning a baseline it cannot justify. No
extra request is needed.
Measured over the live feed, replaying every historical prefix of all 9
pages / 824 releases (725 evaluation points):
page-1 answer vs whole-feed answer 0 divergences
page-1 entries below the answer min 1, p5 33, median 96, max 98
points where the new check fires 0 (identical for all entries
and for eligible ones only)
server_version=None branch min 98 below, 0 firings
modern era (feed newest >= 2024-01-01) 307 points, min 14 below
So the check cannot fire on a healthy feed while still refusing the one
page shape that carries no evidence.
Two supporting corrections:
The endpoint's order was described as `created_at`. It is not: sorting all
824 entries by `created_at` descending does not reproduce the feed order
(164 inversions, 11 of them inside a single page-1 request, maximum
displacement 5 positions; `published_at` and `id` are no better). The
property the fix depends on is about versions across pages, and that does
hold exactly - the maximum version per page is strictly decreasing, 0
violations at the 8 boundaries, and page 1 holds the global maximum. The
wording now says what was measured.
The skip diagnostic was raised from DEBUG to WARNING in an earlier commit
because DEBUG under basicConfig(level=INFO) is what made the original
staleness silent, but nothing pinned the level. The publish-window case now
asserts the record, so reverting the level reddens it.
Also add the resolver to the cache digest of the Upgrade check, the job that
actually runs it. It digests upgrade_runner.sh, which symlinks and invokes
the resolver, but not the resolver itself, so is_affected_by was False for a
resolver-only change and for this pull request; the required
DEB_AMD_RELEASE producers are also unaffected, so nothing else marks the job
affected. Verified with praktika's own code: 12 digested files become 13 and
both queries become True.
…t page The test module promised, unqualified, that the resolved baseline is the newest release strictly below the version under test, while the suite also pins a case returning a release that page 2 supersedes. Scope the promise to the page and state why the page scope is sound and how it fails closed, so the contract the suite advertises is the one it pins. Also correct the cross-page ordering claim in the resolver comment. Read per entry it is false: all 8 current page boundaries have an entry on a later page with a higher version than the previous page's lowest, and the same holds for 714 of 724 historical feed prefixes (live: min(page 1) = v25.3.14.14-lts while max(later pages) = v25.12.3.21-stable). The property the single-page rule depends on is that each page's newest release is older than the previous page's newest, which holds exactly: the per-page maxima 26.7.3.19, 25.12.3.21, 25.1.4.53, 24.1.1.2048, 22.12.3.5, 21.12.1.8816, 21.7.1.7029, 21.4.1.6345, 20.11.1.5003 are strictly decreasing over all 9 pages and 824 releases, 0 violations at the 8 boundaries and 0 over 724 historical prefixes, and page 1 holds the newest release overall. No executable line changes. Suite unchanged at 16 passed, and the eight mutation arms still redden the cases they target.
Internal second-model review (click to expand)Five review rounds. All findings below are adjudicated against the code; the disagreements
Session id: cron:clickhouse-review-slot-8:20260817-235800 |
Pre-PR validation gate (click to expand)
|
|
Workflow [PR], commit [a482dcf] Summary: ✅ AI ReviewSummaryThis PR fixes the reported stale-baseline incident by stopping the previous-release resolver from walking into older GitHub release pages, and it correctly adds the two release-helper entrypoints that Findings
Final VerdictChanges requested: the stale-baseline fix is good, but the release-helper cache coverage is still incomplete and can still skip the very upgrade/download code path this PR is trying to harden. |
|
cc @maxknv, could you review this? The Upgrade check's baseline resolver walked to later pages of the GitHub releases feed when the first page had no usable candidate, and those pages hold only older releases, so it silently validated a 26.8.1.1 build against v25.1.4.53; it now resolves from the first page or raises. |
| @@ -0,0 +1,423 @@ | |||
| """ | |||
| Tests for `get_previous_release_tag`, the resolver that picks the baseline the | |||
| Upgrade check installs and starts before upgrading to the build under test. | |||
There was a problem hiding this comment.
Done in 6f1bd7d - the whole module is gone. I read "both tests" as the test file rather than two of its cases, since they are all in the one file this PR adds; say the word if you meant something narrower.
I also reverted the CI Tests cache digest entry, which only existed so those cases would run against the resolver, so that block is byte-identical to master again. I kept the Upgrade check's digest entry: upgrade_runner.sh symlinks and runs the resolver, so without it a resolver-only change leaves that job cache-skippable, which is the signal loss this PR fixes.
Source fix unchanged. The PR is now source-only: 60 insertions, 29 deletions across the resolver and that one digest line. I dropped the paragraph in the description that claimed new tests.
| while not found: | ||
| response = get_gh_api( | ||
| CLICKHOUSE_TAGS_URL, params={"page": page, "per_page": 100}, timeout=10 | ||
| response = get_gh_api( |
There was a problem hiding this comment.
This shortcut is only correct for the current master-style inputs, but the helper no longer enforces that precondition. With the live releases feed today, get_previous_release(25.12.4.35) returns v25.11.9.34-stable from page 1 even though v25.12.3.21-stable exists on page 2 and is the true newest release below the target. That means older but still valid version inputs now silently resolve to the wrong baseline instead of failing closed. Please either keep paging until you can prove you've crossed below the answer for these inputs, or explicitly raise when server_version is in a range where the one-page assumption is not guaranteed.
There was a problem hiding this comment.
The citation reproduces but the consequence does not: this is pre-existing behaviour, not something this PR introduces.
Same live feed, same input, both arms instrumented for the pages they request:
PRE-FIX (base d59f2be34ed3): 25.12.4.35 -> 25.11.9.34, pages requested=[1]
POST-FIX (this PR): 25.12.4.35 -> 25.11.9.34, pages requested=[1]
Identical. The old page walk stopped at the first page holding any eligible candidate, so it never compared across pages either. "Now silently resolves to the wrong baseline instead of failing closed" describes no change here.
The input is also unreachable in the only workflow that runs this job. server_version is the version of the .deb under test (upgrade_runner.sh:30), and Upgrade check is instantiated only at ci/workflows/pull_request.py:181 with base_branches=[BASE_BRANCH], BASE_BRANCH = "master" (ci/defs/defs.py:46). Master is 26.8.1.1 against a newest release of 26.7.3.19, so the build under test is always above every release; 25.12.4.35 is seven minors below it. In the reachable range page 1 and the whole feed agree (26.8.1.1 -> 26.7.3.19 on both arms).
On the two suggested remedies: "keep paging" is the unbounded while not found: walk this PR removes, and that walk is what produced the reported incident (v25.1.4.53 picked for a 26.8.1.1 build). An explicit raise for that range would fire on an input the workflow cannot produce.
No source change.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
@PedroTadim asked for the tests in this PR to be removed. Dropping ci/tests/test_get_previous_release_tag.py and, with it, the ci_tests cache digest entry that existed only so those cases would run against the resolver; that block is now byte-identical to master again. The Upgrade check digest entry stays: upgrade_runner.sh symlinks and runs the resolver in production, so without it a resolver-only change leaves that job cache-skippable. That is the same signal loss this PR fixes, and it is independent of the tests. The source fix is unchanged.
upgrade_runner.sh symlinks and executes both tests/ci/get_previous_release_tag.py
and tests/ci/download_release_packages.py, but only the resolver was in the job's
digest inputs. A change to the required package prefixes, to the download failure
handling, or to download_last_release could therefore be cached out and never
rerun the Upgrade check, which is the same silently-skipped-release-helper failure
mode this PR exists to fix.
Measured on this branch before the change:
is_affected_by(["./tests/ci/get_previous_release_tag.py"]) = True
is_affected_by(["./tests/ci/download_release_packages.py"]) = False
and after it both return True, while an unrelated path
("./src/Disks/DiskLocal.h") still returns False.
Reported by clickhouse-gh[bot] on ClickHouse#115228.
`get_previous_release_tag` reads page 1 of the GitHub releases list and, since ClickHouse#115228, refuses a page shorter than the 100 releases it asks for, because choosing from or walking past a degraded page gave stale baselines. It refused after a single request, though. GitHub sometimes answers that request with HTTP 200 and `[]`, which `get_gh_api` returns as a success (it retries only on HTTP errors), so one degraded answer killed the job: on 2026-10-22, 14:58-15:32 UTC, `Upgrade check (amd_release)` ended after about a minute with `Unknown job error` on 5 unrelated PRs. Probing the same URL returned `[]` on 4 of 19 requests, each followed by a full page within 10-22 s; answers carry `cache-control: s-maxage=60`, and one empty answer came from the edge cache. Retry a short first page up to 4 times, 60 s apart, so the cached answer has expired before the next request, then raise the same `ReleaseNotFoundException` as before. A full page still costs one request and no wait. HTTP 5xx on the same request is left to ClickHouse#112974. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
The Upgrade check starts a previous release, then upgrades to the build under test.
tests/ci/get_previous_release_tag.pypicks that baseline, and can silently pick one far too old.On PR #114376 commit
e1cb0dee5e9it pickedv25.1.4.53for a26.8.1.1build; that old serveraborted on shutdown, reported as
Received signal 6unrelated to the PR. Two commits earlier itresolved
v26.7.3.19. 4 of 47 recent runs were affected.Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114376&sha=e1cb0dee5e9bd972e9bbbdd8cd8d971ad1e39ee1&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29
Root cause: when no candidate on a page could be used, an unbounded
while not found:advanced topage 2, 3 and answered from there.
/releasesreturns entries roughly newest-created first, not inversion order, and each later page's newest release is older than the previous page's newest
(measured across all 9 pages), so page 1 holds the newest release overall. The only diagnostic was
logger.debugunderbasicConfig(level=INFO).This resolves from the first page only. A candidate still needs an uploaded package, so a release
whose packages are still publishing keeps falling back to the previous patch release, now logged
at WARNING rather than DEBUG. Three cases now raise: a first page with no usable candidate, a page
shorter than the 100 requested, and an answer that is its page's oldest entry, which cannot show
that no newer release precedes it.
upgrade_runner.shturns those nonzero exits into a job failure.No C++ change is needed: the abort is a use-after-free in
25.1, fixed in2920d338ea4(#81473,released in
v25.6.1.3206), so master and every active release branch carry the fix.Tests were removed at review request. The Upgrade check's digest now lists both release helpers
upgrade_runner.shruns, the resolver anddownload_release_packages.py; without them a change toeither leaves the job cache-skippable, the same failure mode fixed here.
Related: #112974 (hardens the API helper; edits the
same digest list, so whichever merges second rebases).
Workflow [PR]
Sync PR [sync-upstream/pr/115228]
Version info
26.8.1.1805(included in26.8and later)