Add @OrderBy to JpaRollout.rolloutGroups to fix rollout on PostgreSQL#3009
Open
clayly wants to merge 1 commit intoeclipse-hawkbit:masterfrom
Open
Add @OrderBy to JpaRollout.rolloutGroups to fix rollout on PostgreSQL#3009clayly wants to merge 1 commit intoeclipse-hawkbit:masterfrom
clayly wants to merge 1 commit intoeclipse-hawkbit:masterfrom
Conversation
The rolloutGroups @onetomany collection lacked an @orderby annotation, leaving the iteration order of rollout groups undefined. Multiple code paths depend on this list being ordered by creation time (ID): - JpaRolloutExecutor uses .get(size()-1) to find the latest group - RolloutHelper.toPercentFromTheRest iterates groups in sequence to calculate target percentages (comment: "assume groups served orderly") - JpaRolloutManagement.resumeRollout gets the last started group by position On H2 (in-memory) rows happen to be returned in insertion order, but PostgreSQL and compatible databases (YugabyteDB, CockroachDB) do not guarantee any ordering without explicit ORDER BY. This caused rollout group status transitions, dynamic group creation, and target assignment to malfunction on PostgreSQL. Adding @orderby("id ASC") makes the JPA provider include ORDER BY when loading the collection, fulfilling the ordering assumption the code already relies on. Verified passing on H2, PostgreSQL 15, and YugabyteDB.
|
Thanks @clayly for taking the time to contribute to hawkBit! We really appreciate this. Make yourself comfortable while I'm looking for a committer to help you with your contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
rolloutGroups@OneToManycollection inJpaRolloutlacks an@OrderByannotation, leaving iteration order undefined. Multiple code paths depend on this list being ordered by creation time (ascending ID):JpaRolloutExecutor.fillDynamicRolloutGroupsWithTargets()uses.get(size()-1)to find the latest dynamic groupJpaRolloutExecutor.handleRunningRollout()uses.get(size()-1)to identify the last groupRolloutHelper.toPercentFromTheRest()iterates groups in sequence to calculate target percentages (comment in code: "assume that the groups are served orderly")JpaRolloutManagement.resumeRollout()takes the last element of a filtered list as the "last started group"On H2 rows happen to be returned in insertion order, but PostgreSQL and compatible databases do not guarantee any ordering without explicit
ORDER BY. This causes:Changes
Added
@OrderBy("id ASC")toJpaRollout.rolloutGroups. This makes the JPA provider includeORDER BYwhen loading the collection, fulfilling the ordering assumption the code already relies on.Test plan
RolloutManagementFlowTest(10 tests) passes on H2 (default)RolloutManagementFlowTest(10 tests) passes on PostgreSQL 15RolloutManagementFlowTest(10 tests) passes on YugabyteDB (PostgreSQL 15.12-YB-2025.2.2.2-b0)