Skip to content

engine/schema: fix missing 4.20.1.0 node in DB upgrade hierarchy#12875

Open
RosiKyu wants to merge 1 commit intoapache:4.20from
shapeblue:fix/upgrade-421010-to-42030-hierarchy
Open

engine/schema: fix missing 4.20.1.0 node in DB upgrade hierarchy#12875
RosiKyu wants to merge 1 commit intoapache:4.20from
shapeblue:fix/upgrade-421010-to-42030-hierarchy

Conversation

@RosiKyu
Copy link
Collaborator

@RosiKyu RosiKyu commented Mar 23, 2026

Direct upgrade from 4.20.1.0 to 4.20.3.0 failed because the upgrade hierarchy skipped the 4.20.1.0 node, causing DatabaseVersionHierarchy to fall back to 4.20.0.0 and re-run Upgrade42000to42010. This triggered a duplicate key violation on configuration_group.name='Usage Server' which already existed from the original 4.20.1.0 install.

  • Add Upgrade42010to42020 no-op upgrader to register 4.20.1.0 in the upgrade hierarchy
  • Register it in DatabaseUpgradeChecker between 4.20.0.0 and 4.20.2.0
  • Harden schema-42000to42010.sql with INSERT IGNORE as a safety net
  • Add unit tests for direct 4.20.1.0->4.20.3.0 and 4.20.2.0->4.20.3.0 upgrade paths

Description

This PR...

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Copilot AI review requested due to automatic review settings March 23, 2026 10:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the DB upgrade version graph so direct upgrades from CloudStack 4.20.1.0 correctly traverse to 4.20.3.0, instead of falling back to 4.20.0.0 and re-running earlier migrations.

Changes:

  • Adds a no-op upgrader for 4.20.1.0 → 4.20.2.0 and registers 4.20.1.0 in DatabaseUpgradeChecker’s version hierarchy.
  • Makes schema-42000to42010.sql resilient to re-execution by changing the configuration_group insert to INSERT IGNORE.
  • Adds unit tests covering the 4.20.1.0 → 4.20.3.0 and 4.20.2.0 → 4.20.3.0 upgrade paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
engine/schema/src/test/java/com/cloud/upgrade/DatabaseUpgradeCheckerTest.java Adds regression tests validating the computed upgrade path for 4.20.x direct upgrades.
engine/schema/src/main/resources/META-INF/db/schema-42000to42010.sql Prevents duplicate-key failure on re-run by using INSERT IGNORE for the “Usage Server” config group.
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42010to42020.java Introduces a no-op upgrader to represent the missing 4.20.1.0 node in the upgrade chain.
engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java Registers the missing 4.20.1.0 node so upgrade path calculation no longer “rounds down” to 4.20.0.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RosiKyu RosiKyu changed the base branch from 4.20.3.0-RC20260320T1916 to 4.20 March 23, 2026 10:25
@nvazquez nvazquez added this to the 4.20.3 milestone Mar 23, 2026
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.25%. Comparing base (c19630f) to head (ac74c37).

Files with missing lines Patch % Lines
...ava/com/cloud/upgrade/dao/Upgrade42010to42020.java 22.22% 14 Missing ⚠️
...ava/com/cloud/upgrade/dao/Upgrade42020to42030.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #12875   +/-   ##
=========================================
  Coverage     16.25%   16.25%           
- Complexity    13415    13416    +1     
=========================================
  Files          5664     5665    +1     
  Lines        500465   500484   +19     
  Branches      60780    60780           
=========================================
+ Hits          81338    81344    +6     
- Misses       410031   410045   +14     
+ Partials       9096     9095    -1     
Flag Coverage Δ
uitests 4.15% <ø> (ø)
unittests 17.10% <25.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@RosiKyu RosiKyu self-assigned this Mar 23, 2026
@RosiKyu RosiKyu force-pushed the fix/upgrade-421010-to-42030-hierarchy branch 2 times, most recently from bff31e5 to 5db8751 Compare March 23, 2026 10:45
@nvazquez
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

-- under the License.

--;
-- Schema upgrade from 4.20.1.0 to 4.20.2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RosiKyu I think, these files are not needed when there is nothing to update in the DB.

throw new CloudRuntimeException("Unable to find " + scriptFile);
}
return new InputStream[]{script};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to override all these methods, default implementations would handle them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sureshanaparti - DbUpgradeAbstractImpl currently provides no default implementations, and DbUpgrade is a plain interface with no defaults either, so all methods need to be explicitly implemented. To avoid touching the interface or the abstract base class in this fix PR (which is scoped to the upgrade path bug), I've kept the full implementation in Upgrade42010to42020.

Copy link
Contributor

@sureshanaparti sureshanaparti Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RosiKyu DbUpgrade has it

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17223

@RosiKyu RosiKyu force-pushed the fix/upgrade-421010-to-42030-hierarchy branch 3 times, most recently from 52ba5a6 to 1736fe6 Compare March 23, 2026 18:37
Direct upgrade from 4.20.1.0 to 4.20.3.0 failed because the upgrade
hierarchy skipped the 4.20.1.0 node, causing DatabaseVersionHierarchy
to fall back to 4.20.0.0 and re-run Upgrade42000to42010. This triggered
a duplicate key violation on configuration_group.name='Usage Server'
which already existed from the original 4.20.1.0 install.

- Add Upgrade42010to42020 no-op upgrader to register 4.20.1.0 in the
  upgrade hierarchy
- Register it in DatabaseUpgradeChecker between 4.20.0.0 and 4.20.2.0
- Harden schema-42000to42010.sql with INSERT IGNORE as a safety net
- Add unit tests for direct 4.20.1.0->4.20.3.0 and 4.20.2.0->4.20.3.0
  upgrade paths
@RosiKyu RosiKyu force-pushed the fix/upgrade-421010-to-42030-hierarchy branch from 1736fe6 to ac74c37 Compare March 23, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants