Repository navigation
backport: fix: Only apply the difference when replacing collection items [DHIS2-22217] - #25492
Merged
jason-p-pickering merged 1 commit intoOct 7, 2026
Merged
Conversation
…-22217] (#25479) * fix: Only apply the difference when replacing collection items [DHIS2-22217] PUT /api/{type}/{uid}/{property} removed every item in the collection and then added every requested item back, even when the list was unchanged. For non-owned collections such as OrganisationUnit.dataSets and OrganisationUnit.programs, each touched item loads and updates its full owning collection (DataSet.sources, Program.organisationUnits). On a large instance, re-sending an org unit's unchanged data sets loaded hundreds of thousands of org units, took 4 to 9 s, set a new lastUpdated on every data set and program, and failed with HTTP 500 when the transaction hit the idle in transaction timeout. The Metadata Management app sends these PUTs on every org unit save. replaceCollectionItems now compares the current and requested UIDs and only removes and adds the difference, so an unchanged list touches nothing. The collection endpoints also only clear the Hibernate caches when the update actually changed something. 🤖 AI Assisted * fix: Reload the object before diffing a non-owned collection For a non-owned property such as OrganisationUnit.dataSets, the replace diff reads the inverse collection, which is in the second-level cache and is not evicted when only the owning side (DataSet.sources) changes: on another cluster node, after an out-of-band change, or when a reader caches it during a metadata import. A stale copy made a re-sent item look unchanged, so the PUT returned 200 with nothing updated and the link stayed missing. Refresh the object first so the inverse collection is read from the database. Evicting the cache entry alone is not enough, as the collection is already loaded into the session by then. An unchanged PUT now runs 3 statements instead of 1 (the object's row and its inverse collection), still independent of the size of the owning collections. 🤖 AI Assisted
|
jbee
approved these changes
Oct 7, 2026
jason-p-pickering
deleted the
fix/DHIS2-22217-collection-replace-diff_2.43
branch
October 7, 2026 14:15
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.



#25479