[
https://jira.jboss.org/jira/browse/DNA-617?page=com.atlassian.jira.plugin...
]
Brian Carothers updated DNA-617:
--------------------------------
Attachment: DNA-617_BJC.patch
Attach patch that corrects the behavior of the BasicJpaConnector with regard to
EntityManager lifetime.
Prior to the patch, the BJC obtained an EntityManager in its constructor and released the
EntityManager in its close method. The typical lifecycle for a connection is a call to
the constructor followed by a single call to execute(...) followed by a call to close().
With this lifecycle, the EntityManager is only used for one call to execute(...) and the
transaction is committed or rolled back after the call as appropriate.
Now that the RepositoryConnectionPool is being used (and was fixed to reuse connections),
the typical lifecycle is one call to the constructor followed by multiple calls to
execute(...) within different transactions followed by (eventually) a call to close().
Since the same EntityManager was being held for the entire life of the BJC object, the
EntityManager would be used for multiple transactions without any attempt being made to
clear out its cache. We're using Hibernate as our JPA implementation, so the
Hibernate session cache was gradually accumulating copies of the data in the database
_that were gradually falling out of sync with the database_.
In other words, BJC1 would be used to create a node and set a property leaving the
ChildEntity and the PropertiesEntity for the node in the Hibernate session cache for
BJC1's EntityManager. BJC2 would then be used to read the same node and update its
property. Since the entities for the node weren't yet in in the session cache for
BJC2's EntityManager, BJC2 would execute select statements to load the necessary data
and would perform the updates. THEN in a subsequent call, BJC1 would be reused to read
from the same node. Since BJC already had the ChildEntity and PropertiesEntity for the
node in its session cache, it would reuse the cached (and now stale) versions instead of
trying to hit the database. Hilarity ensued.
The patch makes BJC obtain an EntityManager at the beginning of the execute(...) call and
release the EntityManager at the end of the execute(...) call. Since "released"
EntityManager objects are really closed by the EntityManagers factory object, this will
cure the session cache issue.
NPE while updating indexes (during integration tests)
-----------------------------------------------------
Key: DNA-617
URL:
https://jira.jboss.org/jira/browse/DNA-617
Project: DNA
Issue Type: Bug
Components: JCR, Query, Search
Affects Versions: 0.7
Reporter: Randall Hauch
Assignee: Brian Carothers
Priority: Blocker
Fix For: 0.7
Attachments: DNA-617_BJC.patch, DNA-617_connector.patch, DNA-617_FixForNPE.patch,
DNA-617_test.patch
This happened on the nightly integration tests, but did not happen during the continuous
integration tests. So while I'm not sure how repeatable it is, there is at least a
stack trace:
java.lang.IllegalStateException: Failed to initialize the repository with text content.
at org.jboss.dna.jcr.DnaRepositoryStub.configureRepository(DnaRepositoryStub.java:140)
at org.jboss.dna.jcr.DnaRepositoryStub.getRepository(DnaRepositoryStub.java:157)
at org.jboss.dna.jcr.DnaRepositoryStub.getRepository(DnaRepositoryStub.java:41)
at org.apache.jackrabbit.test.RepositoryHelper.getRepository(RepositoryHelper.java:68)
at org.apache.jackrabbit.test.RepositoryHelper.getProperty(RepositoryHelper.java:150)
at org.apache.jackrabbit.test.AbstractJCRTest.getProperty(AbstractJCRTest.java:442)
at org.apache.jackrabbit.test.AbstractJCRTest.setUp(AbstractJCRTest.java:264)
at org.apache.jackrabbit.test.api.RootNodeTest.setUp(RootNodeTest.java:47)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at org.apache.jackrabbit.test.AbstractJCRTest.run(AbstractJCRTest.java:406)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.lang.NullPointerException
at
org.jboss.dna.graph.search.SearchEngineIndexer.indexSubgraph(SearchEngineIndexer.java:294)
at org.jboss.dna.graph.search.SearchEngineIndexer.index(SearchEngineIndexer.java:227)
at org.jboss.dna.graph.search.SearchEngineIndexer.index(SearchEngineIndexer.java:135)
at
org.jboss.dna.jcr.RepositoryQueryManager$SelfContained.reindexContent(RepositoryQueryManager.java:334)
at
org.jboss.dna.jcr.RepositoryQueryManager$SelfContained.<init>(RepositoryQueryManager.java:292)
at org.jboss.dna.jcr.JcrRepository.<init>(JcrRepository.java:593)
at org.jboss.dna.jcr.JcrEngine.doCreateJcrRepository(JcrEngine.java:257)
at org.jboss.dna.jcr.JcrEngine.getRepository(JcrEngine.java:175)
at org.jboss.dna.jcr.DnaRepositoryStub.configureRepository(DnaRepositoryStub.java:120)
at org.jboss.dna.jcr.DnaRepositoryStub.getRepository(DnaRepositoryStub.java:157)
at org.jboss.dna.jcr.DnaRepositoryStub.getRepository(DnaRepositoryStub.java:41)
at org.apache.jackrabbit.test.RepositoryHelper.getRepository(RepositoryHelper.java:68)
at org.apache.jackrabbit.test.RepositoryHelper.getProperty(RepositoryHelper.java:150)
at org.apache.jackrabbit.test.AbstractJCRTest.getProperty(AbstractJCRTest.java:442)
at org.apache.jackrabbit.test.AbstractJCRTest.setUp(AbstractJCRTest.java:264)
at org.apache.jackrabbit.test.api.RootNodeTest.setUp(RootNodeTest.java:47)
at junit.framework.TestCase.runBare(TestCase.java:132)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira