[
https://issues.apache.org/jira/browse/ISIS-1134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14500638#comment-14500638
]
Martin Grigorov commented on ISIS-1134:
---------------------------------------
After reading some more JDO documents and articles in the web I believe this
two commits should be the proper fix here.
Unfortunately now isis-module-security fails during executing its seeds:
Caused by: javax.jdo.JDODataStoreException: Insert of object
"org.isisaddons.module.security.dom.role.ApplicationRole@556a5b6c" using
statement "INSERT INTO IsisAddonsSecurity."ApplicationRole"
("name","description") VALUES (?,?)" failed : integrity constraint violation:
unique constraint or index violation; "ApplicationRole_name_UNQ" table:
"ApplicationRole"
NestedThrowables:
java.sql.SQLIntegrityConstraintViolationException: integrity constraint
violation: unique constraint or index violation; "ApplicationRole_name_UNQ"
table: "ApplicationRole"
at
org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:451)
at
org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:732)
at
org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:752)
at
org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucleusCreateObjectCommand.execute(DataNucleusCreateObjectCommand.java:54)
at
org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.executeCommands(DataNucleusObjectStore.java:361)
at
org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.execute(DataNucleusObjectStore.java:355)
at
org.apache.isis.core.runtime.system.transaction.IsisTransaction.doFlush(IsisTransaction.java:521)
at
org.apache.isis.core.runtime.system.transaction.IsisTransaction.flush(IsisTransaction.java:467)
at
org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.flushTransaction(IsisTransactionManager.java:392)
at
org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession$7.flush(RuntimeContextFromSession.java:238)
at
org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault.flush(DomainObjectContainerDefault.java:261)
at
org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault.firstMatch(DomainObjectContainerDefault.java:554)
at
org.isisaddons.module.security.dom.permission.ApplicationPermissions.findByRoleAndRuleAndFeature(ApplicationPermissions.java:175)
at
org.isisaddons.module.security.dom.permission.ApplicationPermissions.newPermissionNoCheck(ApplicationPermissions.java:221)
at
org.isisaddons.module.security.seed.scripts.AbstractRoleAndPermissionsFixtureScript.newPermissions(AbstractRoleAndPermissionsFixtureScript.java:110)
at
org.isisaddons.module.security.seed.scripts.AbstractRoleAndPermissionsFixtureScript.newClassPermissions(AbstractRoleAndPermissionsFixtureScript.java:73)
at
org.isisaddons.module.security.seed.scripts.IsisModuleSecurityRegularUserRoleAndPermissions.execute(IsisModuleSecurityRegularUserRoleAndPermissions.java:46)
at
org.apache.isis.applib.fixturescripts.FixtureScript$ExecutionContext.executeChildIfNotAlready(FixtureScript.java:549)
at
org.apache.isis.applib.fixturescripts.FixtureScript$ExecutionContext.executeChildT(FixtureScript.java:528)
at
org.apache.isis.applib.fixturescripts.FixtureScript$ExecutionContext.executeChildT(FixtureScript.java:498)
at
org.apache.isis.applib.fixturescripts.FixtureScript$ExecutionContext.executeChild(FixtureScript.java:487)
at
org.isisaddons.module.security.seed.SeedUsersAndRolesFixtureScript.execute(SeedUsersAndRolesFixtureScript.java:43)
...
I also think that DataNucleus should close all opened queries when the
PersistenceManager that have created them is being closed. For some reason this
is not the case.
> DN connections leak due to non-closed queries (?!)
> --------------------------------------------------
>
> Key: ISIS-1134
> URL: https://issues.apache.org/jira/browse/ISIS-1134
> Project: Isis
> Issue Type: Bug
> Components: Core
> Affects Versions: core-1.8.0
> Reporter: Martin Grigorov
> Assignee: Dan Haywood
>
> My application failed twice with OutOfMemoryError in heap space so I've
> dumped a .hprof of its memory (jmap -dump:format=b,file=some-file.hprof) and
> analyzed it with Eclipse MAT (https://eclipse.org/mat/).
> It appears that there are many org.datanucleus.store.rdbms.query.JDOQLQuery$2
> objects.
> JDOQLQuery$2 appears to be ManagedConnectionResourceListener (
> https://github.com/datanucleus/datanucleus-rdbms/blob/651c77ff3b2af76ada97d14b537cd41fb0524a0c/src/java/org/datanucleus/store/rdbms/query/JDOQLQuery.java#L740).
> The listener is removed only when
> org.datanucleus.store.query.AbstractQueryResult#close() method is called.
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindAllInstancesProcessor#process()
> does:
> {code}
> final List<?> pojos = (List<?>) jdoQuery.execute();
> return loadAdapters(specification, pojos);
> {code}
> So it consumes the result and returns ObjectAdapter for each pojo but it
> doesn't close the Query.
> AFAIK open-session-in-view pattern is not used in Isis so the resources
> should be closed explicitly after usage.
> A simple solution is to try/finally this code and close the query but I may
> miss some detail here.
> Related: recently I've profiled the application with Yourkit and it showed
> that DomainObjectContainer#allMatches() method is slow in one of the use
> cases. Some quick investigation showed that DomainObjectContainer delegates
> the work to
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryProcessor#process().
> It loads the POJOs from the DB, then wraps them in ObjectAdapters, and
> finally
> org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault#allMatches(org.apache.isis.applib.query.Query<T>)
> unwraps them back to POJOs.
> Why this is done?
> This solves the issue of "consume the QueryResult before closing it" for the
> memory leak issue but it also adds to the processing time.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)