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

Flush in PersistenceDelegator fails in multi-threaded environment #481

Closed
yeshvanthni opened this issue Dec 20, 2013 · 11 comments
Closed

Flush in PersistenceDelegator fails in multi-threaded environment #481

yeshvanthni opened this issue Dec 20, 2013 · 11 comments

Comments

@yeshvanthni
Copy link

A number of Concurrency related issues which are not exactly reproducible in a tescase are seen in load or stress test environment.

The following are a few examples,

java.util.ConcurrentModificationException
at java.util.ArrayDeque$DeqIterator.next(ArrayDeque.java:632)
at java.util.AbstractCollection.toString(AbstractCollection.java:449)
at java.lang.String.valueOf(String.java:2854)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at com.impetus.kundera.persistence.PersistenceDelegator.flush(PersistenceDelegator.java:420)
at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:175)
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:171)
... 10 more

--or--

java.util.NoSuchElementException
at java.util.ArrayDeque.removeFirst(ArrayDeque.java:278)
at java.util.ArrayDeque.pop(ArrayDeque.java:507)
at com.impetus.kundera.persistence.PersistenceDelegator.flush(PersistenceDelegator.java:391)
at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:151)
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:168)
... 14 more

Observations:
-ReentrantReadWriteLock which are acquired for all other operations in PesistenceDelegator is not acquired for flush. It is presumed that the lock would have been acquired in a different method by the same thread prior to reaching flush.

-entitManager.flush() calls flush without acquiring a lock and if a code has persist and explicit flush in a multi-threaded environment this assumption is violated and we are seeing thread errors.

-if by design, flush will not acquire any lock then it should use thread-safe classes like ConcurrentHashMap for eventLogs and ConcurrentLinkedDeque for flushStack.

Let me know if you need further information

@ghost ghost assigned mevivs Dec 21, 2013
@mevivs
Copy link
Collaborator

mevivs commented Dec 21, 2013

@yeshvanthni

-if by design, flush will not acquire any lock then it should use thread-safe classes like ConcurrentHashMap for eventLogs and ConcurrentLinkedDeque for flushStack.

Thanks for raising this issue. This We are working on it and will be fixed and released in 2.10. Will post an update once done in current trunk.

-Vivek

@mevivs
Copy link
Collaborator

mevivs commented Dec 23, 2013

A fix has been added for this resolve this issue on trunk.

-Vivek

@ghost ghost assigned kkmishra Dec 30, 2013
@pires
Copy link
Contributor

pires commented Jan 2, 2014

+1

@yeshvanthni
Copy link
Author

Could this be made available as a hotfix on an earlier stable release?

@mevivs
Copy link
Collaborator

mevivs commented Jan 2, 2014

We are planning for a maintenance release(before 2.10). will post an update once we finalize on it's date.

@yeshvanthni
Copy link
Author

Thank you for making the fix available. We are continuing to test with snapshot. When can we expect the maintenance release? This is a blocking issue and its being seen within half an hour of starting the application and in 2-3 mins of load testing.

@mevivs
Copy link
Collaborator

mevivs commented Jan 8, 2014

Possibly by next week. i will post an update on this.

-Vivek

@yeshvanthni
Copy link
Author

Is this fix available in 2.9.1 release.?

@mevivs
Copy link
Collaborator

mevivs commented Jan 15, 2014

Yes. Releasing today with 2.9.1

-Vivek

@mevivs
Copy link
Collaborator

mevivs commented Jan 15, 2014

Fixed. Releasing with 2.9.1

-Vivek

Note: Group artifactId has been changed. Please refer https://github.com/impetus-opensource/Kundera/blob/trunk/src/README.md#note for the same.

@mevivs mevivs closed this as completed Jan 15, 2014
@yeshvanthni
Copy link
Author

Thanks

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

No branches or pull requests

4 participants