Fix for ConcurrentMod Exception seen in DatasetsIT test#12128
Open
qqmyers wants to merge 3 commits intoIQSS:developfrom
Open
Fix for ConcurrentMod Exception seen in DatasetsIT test#12128qqmyers wants to merge 3 commits intoIQSS:developfrom
qqmyers wants to merge 3 commits intoIQSS:developfrom
Conversation
e758ca1 to
e64a9e2
Compare
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.
What this PR does / why we need it: I saw a500 error in at
edu.harvard.iq.dataverse.api.DatasetsIT.testSummaryDatasetVersionsDifferencesAPI(DatasetsIT.java:6629)on #12063 and think I've seen it before. Looking in the server log I sawand investigating with some AI help, it appears that the ~root problem is that the code was modifying a (managed) array that may be used in multiple threads.
The fix here should prevent that via synchronization and avoiding using the same list in new copies of the FileMetadata while still addressing the issue of seeing an IndirectList that led to the original code.
Which issue(s) this PR closes:
Special notes for your reviewer: Aside from adding synchronization, this PR makes some changes to code that was copying from one filemetadata to another - reusing/extending the createCopy instead of having redundant code. (createCopyInVersion now makes sure the calls to set the version in the fmd and to add the fmd to the version's list are done rather than making those separate calls). That fixes a couple cases where there was a fmd2.setCategories(fmd1.getCategories()) (sharing the same managed array across fmds) which should be OK. I also realized the createCopy wasn't copying any prov entry which I assume it should have been doing?
Suggestions on how to test this: Regression-only -we shouldn't see any new errors. The IT tests should get this error any more, but it was pretty rare already.
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Is there a release notes update needed for this change?:
Additional documentation: