Jackrabbit Content Repository
  1. Jackrabbit Content Repository
  2. JCR-2796

Restoring a node fails (partially) if done within a XA transaction

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.2
    • Component/s: jackrabbit-core
    • Labels:
      None
    • Environment:
      Jackrabbit 2.1.1

      Description

      A problem occurs with the following sequence of steps:

      1) Create a versionable node that has a child and a grandchild.
      2) Perform a check-in of the versionable node and give a version-label.
      3) Perform a restore by using the version-label.
      4) Access the grandchild.

      Step 4 fails, if step 3 is executed within a transaction. If no transaction is used, then step 4 succeeds.
      The test-case attached below can be executed within XATest.java (http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java).

      public void testRestore() throws Exception {
      Session session = null;
      try {
      session = getHelper().getSuperuserSession();

      // make sure that 'testNode' does not exist at the beginning of the test
      for (NodeIterator ni = session.getRootNode().getNodes(); ni.hasNext() {
      Node aNode = ni.nextNode();
      if (aNode.getName().equals("testNode"))

      { aNode.remove(); }

      }

      // 1) create 'testNode' that has a child and a grandchild
      session.getRootNode().addNode("testNode").addMixin(NodeType.MIX_VERSIONABLE);
      session.getRootNode().getNode("testNode").addNode("child").addNode("grandchild");
      session.save();

      // 2) check in 'testNode' and give a version-label
      Version version = session.getWorkspace().getVersionManager().checkin(
      session.getRootNode().getNode("testNode").getPath());
      session.getWorkspace().getVersionManager().getVersionHistory(
      session.getRootNode().getNode("testNode").getPath()).addVersionLabel(version.getName(),
      "testLabel", false);

      // 3) do restore by label
      UserTransaction utx = new UserTransactionImpl(session);
      utx.begin();
      session.getWorkspace().getVersionManager().restoreByLabel(
      session.getRootNode().getNode("testNode").getPath(), "testLabel", true);
      utx.commit();

      // 4) try to get the grandchild (fails if the restoring has been done within a transaction)
      session.getRootNode().getNode("testNode").getNode("child").getNode("grandchild");
      } finally {
      if (session != null)

      { session.logout(); }

      }
      }

        Activity

        Jukka Zitting made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Jukka Zitting made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Jukka Zitting [ jukkaz ]
        Fix Version/s 2.2.0 [ 12314844 ]
        Resolution Fixed [ 1 ]
        Hide
        Jukka Zitting added a comment -

        Thanks for reporting this, and for including a good test case! Fixed in revision 1032770.

        Show
        Jukka Zitting added a comment - Thanks for reporting this, and for including a good test case! Fixed in revision 1032770.
        Jukka N committed 1032770 (2 files)
        Reviews: none

        JCR-2796: Restoring a node fails (partially) if done within a XA transaction

        The restore operation can produce a ChangeLog that both adds and removes
        (instead of just modifying) the same item states. The internal caching
        logic expects this behaviour, but the ChangeLog.merge() logic used in
        transactions would automatically convert such add/remove pairs to
        individual modifications. This change modifies the merge() logic to
        leave such add/remove pairs intact.

        Dominik Klaholt created issue -

          People

          • Assignee:
            Jukka Zitting
            Reporter:
            Dominik Klaholt
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development