Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0] Bugfix: java.util.ConcurrentModificationException at IdentityMa… #1291

Open
wants to merge 1 commit into
base: 3.0
Choose a base branch
from

Conversation

ivvlev
Copy link

@ivvlev ivvlev commented Sep 9, 2021

…pManager.invalidateQueryCache

PROBLEM

ConcurrentModificationException raising while evicting shared caches.

CAUSE

Set 'invalidations' is changing in while we iterate over it.

SOLVING

Add thread synchronization

Signed-off-by: Vladimir Ivanov ivvlev@ivvlev.com

…pManager.invalidateQueryCache

PROBLEM
=======
ConcurrentModificationException raising while evicting shared caches.

CAUSE
=======
Set 'invalidations' is changing in while we iterate over it.

SOLVING
=======
Add thread synchronization

Signed-off-by: Vladimir Ivanov <ivvlev@ivvlev.com>
@ivvlev
Copy link
Author

ivvlev commented Sep 9, 2021

Eclipselink3_Bug_ConcurAccess.zip
Sample project

@rfelcman
Copy link
Contributor

Sorry, but there are test failures see continuous-integration/jenkins/pr-merge . This is major blocker for PR approval.

@ivvlev
Copy link
Author

ivvlev commented Nov 16, 2021

there are test failures see continuous-integration/jenkins/pr-merge

@rfelcman I consider that it's not my fault.
My PR1291, PR1292 and not my PR1290, PR1285, PR1271 has same faults in tests in Jenkins logs.
My PRs was made at 2021 september 9, same faults in tests starts since 2021 september 3.

@Alexey-NM
Copy link
Contributor

Sorry, but there are test failures see continuous-integration/jenkins/pr-merge . This is major blocker for PR approval.

There are no failures currently, what can we do to get PR approval?

this.queryResults.remove(queryKey);
synchronized (this.queryResults) {
for (Object queryKey : invalidations) {
this.queryResults.remove(queryKey);

Choose a reason for hiding this comment

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

The queryResults is a ConcurrentHashMap. Could be rewritten to if (this.queryResults.keySet().removeAll(invalidations) invalidations.clear() so that locking is avoided?

Copy link
Author

Choose a reason for hiding this comment

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

Problem is modification of invalidations while it's iterating.
The code can be rewritten according to your suggestion, but this will not eliminate the need of synchronization. Internally java.util.concurrent.ConcurrentHashMap.CollectionView#removeAll can iterate invalidations allso.

PS If invalidations.size() > queryResults.size() the CollectionView#removeAll will work faster then for (Object queryKey : invalidations) {}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants