5 Replies Latest reply on Jul 23, 2015 12:08 PM by ibodrov

    Modeshape 4: transactional changes visibility bug?

    ibodrov

      Hello!

       

      After upgrade from 3.8.x to 4.3.0, we've got a bug while working with transactions: some changes are not visible outside. We've managed to reproduce it with this test case: Test.java · GitHub
      This code can be copy-pasted into TransactionsTest.java in current master branch.

       

      Expected result: node removed inside transaction should be visible before commit (STEP 5) and gone after (STEP 7).

      Actual result: node is visible before commit (STEP 5) and still present after (STEP 7).

       

      Is there something wrong with this code, configuration or is it a bug?

       

      Thanks.

       

      Message was edited by: Ivan Bodrov

        • 1. Re: Modeshape 4: transactional changes visibility bug?
          hchiorean

          While there may be an issue somewhere, the test case is highly unusual: you're starting a transaction off thread X and then suspending & resuming the same transaction of threads Y, Z etc. So essentially you're "forcibly" changing the [thread,tx] association for the same transaction. While the transaction API doesn't prevent you from doing this, IMO it's not a regular test case/usage pattern.

          If for example, you keep the start/suspend/resume off the same thread in your test case (e.g. the main thread) the code runs fine. I will investigate this some more, but in the meantime as a workaround try to avoid forcibly changing the tx/thread association and keep the suspend/resume call to the same thread where the transaction was originally started from.

          • 2. Re: Modeshape 4: transactional changes visibility bug?
            ibodrov

            Well, thats the point - we are using "long" transactions in our application which spans across multiple threads.
            We had it working pretty well in Mode 3.x and i think in Mode 4.0 beta but not in Mode 4.3

            • 3. Re: Modeshape 4: transactional changes visibility bug?
              hchiorean

              Spanning across multiple threads - i.e. separate threads having their own transactions while the "main" one is being suspended  - is not the problem. The problem is these threads are committing a transaction which was not originally spawned for them. This is not a typical "long transaction" use case IMO.

               

              Running your test case on 3.8.1.Final on my machine produces the following output:

               

              12:13:35,959  WARN ISPN000100: Stopping, but there are 1 local transactions and 0 remote transactions that did not finish in time.
              
              java.lang.AssertionError: Found a child reference in /{}parent/{}nested to a non-existant child {}child
                  at org.modeshape.jcr.JcrSession.cachedNode(JcrSession.java:614)
                  at org.modeshape.jcr.JcrSession.node(JcrSession.java:641)
                  at org.modeshape.jcr.JcrSession.node(JcrSession.java:660)
                  at org.modeshape.jcr.JcrSession.getNode(JcrSession.java:844)
                  at org.modeshape.jcr.JcrSession.getNode(JcrSession.java:827)
                  at org.modeshape.jcr.JcrSession.getNode(JcrSession.java:134)
                  at org.modeshape.jcr.TransactionsTest.testCommit(TransactionsTest.java:492)
              

               

              so I doubt this type of scenario works correctly in 3.x.

              • 5. Re: Modeshape 4: transactional changes visibility bug?
                ibodrov

                Thanks! I'll try to workaround by pinning the transaction's thread.