[ 
https://issues.apache.org/jira/browse/OPENJPA-2330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13574395#comment-13574395
 ] 

Guillaume Chauvet commented on OPENJPA-2330:
--------------------------------------------

Hello,

So sorry I was not able to provide you with more detailed information from the 
start, but unfortunately I didn't have the time yesterday as we are approaching 
deadline for release of new software.
I am working on creating a unit test, however I will not be able to provide it 
straight away as I haven't been able to reproduce the bug, even though our 
software crashes systematically.
So I think I will first create a patch for our version of OpenJPA to rectify 
the problem, then generate the unit test(s), as with the last bug report I made.

The environment we use is OpenJPA 2.2.1 in a thick client Swing (JRE 1.6_39 64 
bits). We operate an Apache Derby 10.8.2.2 database in client/server mode.
Belowlisted the scenario in which the problematic memory overflow occurs in our 
application:
 
Prerequisites:
==========
- 3 classes of entities "EntityA", "EntityB", "EntityC"
- bidirectional navigation between classes:
                - Cardinality OneToMany between EntityA and EntityB with the 
following parameters: fetch = FetchType.EAGER, mappedBy = "entitya", 
orphanRemoval = true, cascade = CascadeType.ALL
                - Cardinality OneToMany between EntityB and EntityC with the 
following parameters: fetch = FetchType.EAGER, mappedBy = "entityb", 
orphanRemoval = true, cascade = CascadeType.ALL
                - EntityC is associated with alot of other tables, which I 
won't list for now.
 
 
Parameterization of OpenJPA:
==========
<properties>
        <property name="openjpa.InverseManager" value="true"/>
        <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
        <property name="openjpa.jdbc.SchemaFactory" 
value="native(ForeignKeys=true)"/>
        <property name="openjpa.jdbc.MappingDefaults" 
value="ForeignKeyDeleteAction=restrict, JoinForeignKeyDeleteAction=restrict"/>
        <property name="openjpa.Multithreaded" value="true"/>
        <property name="openjpa.MaxFetchDepth" value="1"/>
        <property name="openjpa.NontransactionalWrite" value="true"/>
        <property name="openjpa.FetchBatchSize" value="0"/>
</properties
 
Initial state:
==========
The data base already contains an entities tree depth level 3 organized as 
follows:
* 2 instances of type "EntityA" type : A1, A2
* 2 instances of "EntityB" type : B1, B2
* 3 instances of "EntityC" type : C1, C2, C3
 
-> Representation of the entity linking 
A1 -> [B1 -> [C1, C2]]
A2 -> [B2 -> [C3]]
 
 
Scenario:
=================
1) 2 new instances of EntityC "C4" & "C5" type occurrences are inserted into 
entity B2:
                * State of the graph following insertion:
                               A1 -> [B1 -> [C1, C2]]
                               A2 -> [B2 -> [C3, C4, C5]]
 
2) Only entities A1 & A2 are persisted in two consecutive transactions. 
=> First persist on entity A1
                * State of the graph following commit:
                               A1 -> [B1 -> [C1, C2]]
                               A2 -> [B2 -> []]  => C3 was deleted during the 
first persist (new problem which we hadn't remarked yesterday).
 
=> Second persist on entity A2
                * State of the graph following insertion:
                               A1 -> [B1 -> [C1, C2]]
                               A2 -> [B2 -> [C4, C5]]     => Memory overflow, 
causing loss of entities C4, C5.
Urgent solution
=================
We are going to create a homemade corrective patch in order to mark the 
relations crossed between entities in the  «OpenJPAPersistenceUtil » class in 
order to avoid all looping.
                
> Stackoverflow due to endless recursive calls
> --------------------------------------------
>
>                 Key: OPENJPA-2330
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2330
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.2.0, 2.2.1
>            Reporter: Guillaume Chauvet
>            Priority: Critical
>
> We wish to report another bug that generates a memory overflow resulting in 
> an infinite recursive loop. Here are two stacktraces apparently from the same 
> bug:
> First stacktrace sample :
> ================================================
> Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
>       at java.util.LinkedHashMap$KeyIterator.<init>(LinkedHashMap.java:383)
>       at java.util.LinkedHashMap$KeyIterator.<init>(LinkedHashMap.java:383)
>       at java.util.LinkedHashMap.newKeyIterator(LinkedHashMap.java:396)
>       at java.util.HashMap$KeySet.iterator(HashMap.java:874)
>       at java.util.HashSet.iterator(HashSet.java:153)
>       at 
> org.apache.openjpa.util.java$util$LinkedHashSet$proxy.iterator(Unknown Source)
>       at java.util.AbstractCollection.toArray(AbstractCollection.java:120)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedCollection(OpenJPAPersistenceUtil.java:240)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:212)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedArray(OpenJPAPersistenceUtil.java:265)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedCollection(OpenJPAPersistenceUtil.java:242)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:212)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:223)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:223)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedArray(OpenJPAPersistenceUtil.java:265)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedCollection(OpenJPAPersistenceUtil.java:242)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:212)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:223)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
> [...]
> Second stacktrace sample :
> ================================================
> Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
>       at java.util.HashMap$EntrySet.size(HashMap.java:963)
>       at 
> org.apache.openjpa.util.ProxyMaps$ProxyEntrySetImpl.size(ProxyMaps.java:255)
>       at java.util.AbstractCollection.toArray(AbstractCollection.java:119)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedMap(OpenJPAPersistenceUtil.java:288)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:215)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedArray(OpenJPAPersistenceUtil.java:265)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedCollection(OpenJPAPersistenceUtil.java:242)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:212)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedArray(OpenJPAPersistenceUtil.java:265)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedCollection(OpenJPAPersistenceUtil.java:242)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:212)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:223)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoadedField(OpenJPAPersistenceUtil.java:223)
>       at 
> org.apache.openjpa.persistence.OpenJPAPersistenceUtil.isLoaded(OpenJPAPersistenceUtil.java:161)
> [...]

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to