Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1360

ConcurrentModificationException when session reads content being modified

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Blocker
    • 3.0.0.Beta2
    • 3.0.0.Alpha1
    • JCR
    • None

    Description

      When there are multiple sessions reading a node (e.g., reading the child references) while other sessions modify that node (e.g., add a child node), the reading sessions occasionally get a ConcurrentModificationException. This is happening because the Documents stored in Infinispan are being modified within a transaction, but the cached nodes in the workspace still have a reference to the now-changing Document content.

      I created a test that submits 100 runnables to an executor (with a max of 50 threads), where each runnable obtains a session, adds a new uniquely-named node under the root node, saves the change, and then logs out. During most runs, one or two of the 100 threads get the following exception:

      java.util.ConcurrentModificationException
      	at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
      	at java.util.AbstractList$Itr.next(AbstractList.java:343)
      	at org.infinispan.schematic.internal.document.BasicArray$2.next(BasicArray.java:277)
      	at org.modeshape.jcr.cache.document.DocumentTranslator.getChildReferences(DocumentTranslator.java:738)
      	at org.modeshape.jcr.cache.document.LazyCachedNode.getChildReferences(LazyCachedNode.java:281)
      	at org.modeshape.jcr.AbstractJcrNode.addChildNode(AbstractJcrNode.java:989)
      	at org.modeshape.jcr.AbstractJcrNode.addNode(AbstractJcrNode.java:953)
      	at org.modeshape.jcr.AbstractJcrNode.addNode(AbstractJcrNode.java:874)
      	at org.modeshape.jcr.AbstractJcrNode.addNode(AbstractJcrNode.java:1)
      	at org.modeshape.jcr.ModeShapeTckTest$1.run(ModeShapeTckTest.java:2541)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      	at java.lang.Thread.run(Thread.java:680)
      

      Attachments

        Issue Links

          Activity

            People

              hchiorean Horia Chiorean (Inactive)
              rhauch Randall Hauch (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: