Concurrent modifications to the repository can result in org.modeshape.jcr.cache.NodeNotFoundInParentException
ma6rl Jan 4, 2016 4:51 PMI am using the Modeshape 4.5.0.Final Wildfly Kit with the following infinispan configuration:
<?xml version="1.0" encoding="UTF-8"?> <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:7.0 http://www.infinispan.org/schemas/infinispan-config-7.0.xsd urn:infinispan:config:store:jdbc:7.0 http://docs.jboss.org/infinispan/schemas/infinispan-cachestore-jdbc-config-7.0.xsd" xmlns="urn:infinispan:config:7.0"> <jgroups> <stack-file name="tcp" path="${jboss.server.config.dir}/modeshape/jgroups-config.xml"/> </jgroups> <cache-container default-cache="omakase-repo" statistics="false"> <transport cluster="modeshape-cluster" stack="tcp"/> <jmx duplicate-domains="true"/> <replicated-cache name="repo" mode="SYNC"> <locking striping="false" isolation="READ_COMMITTED"/> <transaction mode="NON_DURABLE_XA" locking="PESSIMISTIC"/> <eviction max-entries="200000" strategy="LIRS"/> <expiration interval="-1"/> <persistence passivation="false"> <string-keyed-jdbc-store xmlns="urn:infinispan:config:store:jdbc:7.0" fetch-state="false" read-only="false" purge="false" shared="true"> <data-source jndi-url="java:jboss/datasources/DS"/> <string-keyed-table prefix="modeshape" create-on-start="true" drop-on-exit="false"> <id-column name="id" type="VARCHAR(200)"/> <data-column name="datum" type="LONGBLOB"/> <timestamp-column name="version" type="BIGINT"/> </string-keyed-table> </string-keyed-jdbc-store> </persistence> </replicated-cache> </cache-container> </infinispan>
- I am using indexes but have been able to recreate the issue without indexes, it just occurs more frequently with indexes.
- I do have eviction enabled but have been able to recreate the issue with eviction disabled.
- I am using container managed transactions with each update is happening in it's own Tx.
The issue occurs when several threads are making concurrent updates to the same repository. Each thread starts and commits it's own Tx (via container managed transactions). The problem seems to appear after the following error occurs during an update:
12:43:18,820 ERROR [org.jboss.as.ejb3] (default task-7) javax.ejb.EJBTransactionRolledbackException: javax.jcr.RepositoryException: org.modeshape.jcr.TimeoutException: Timeout while attempting to lock the keys [f5e46727505d6451e1455a-9fd2-4530-a3f0-7265f7e546c1] after 0 retry attempts. Caused by: org.modeshape.jcr.TimeoutException: Timeout while attempting to lock the keys [f5e46727505d6451e1455a-9fd2-4530-a3f0-7265f7e546c1] after 0 retry attempts. at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:670) [modeshape-jcr-4.5.0.Final.jar:4.5.0.Final] at org.modeshape.jcr.JcrSession.save(JcrSession.java:1171) [modeshape-jcr-4.5.0.Final.jar:4.5.0.Final] ... 154 more Caused by: org.infinispan.util.concurrent.TimeoutException: Timeout while attempting to lock the keys [f5e46727505d6451e1455a-9fd2-4530-a3f0-7265f7e546c1] after 0 retry attempts. at org.modeshape.jcr.cache.document.WritableSessionCache.lockNodes(WritableSessionCache.java:1495) [modeshape-jcr-4.5.0.Final.jar:4.5.0.Final] at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:638) [modeshape-jcr-4.5.0.Final.jar:4.5.0.Final] ... 155 more
Once this error occurs the modeshape repository can be left in an inconsistent state where a child node exists and references a parent node, but the parent node does not contain a reference to the child node hence the org.modeshape.jcr.cache.NodeNotFoundInParentException. As you can see from the stack trace above the transaction is rollback by the container but it seems like a child node is not being correctly cleaned up.
I am currently working on a test-app that can demonstrate this problem, once I have that I plan to open a JIRA but in the mean time if you have any ideas about how I can work around this I would appreciate any help you can provide.