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

Sometimes query returns duplicated records after commiting a transaction that contains VersionManager.checkin() call when using a real JTA transaction manager

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.2.0.Final
    • 3.1.3.Final
    • Query, Transactions
    • None

    Description

      May relate to MODE-1822

      After committing a transaction that create a new versionable node and then call VersionManager.checkin(), query may return duplicated record for that newly created node.

      A more complex case can reproduce this issue almost every time

              @Transactional
              public void createMultipleNodes(JCRSessionHolder sessionHolder) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException {
                  for (int i = 0; i < 10; ++i) {
                      createNewNode("Test" + i, sessionHolder);
                  }
              }
      
              private void createNewNode(String name, JCRSessionHolder sessionHolder) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException {
                  VersionManager vm = sessionHolder.getSession().getWorkspace().getVersionManager();
                  Node node = sessionHolder.getSession().getRootNode()
                          .addNode(name, "pd:product");
                  node.addMixin("mix:versionable");
                  node.setProperty("name", "lalalal");
                  node.setProperty("code", "lalalal");
                  
                  createChildNode(node);
                  
                  sessionHolder.getSession().save();
                  vm.checkin(node.getPath());
                  vm.checkout(node.getPath());
              }
              
              private void createChildNode(Node parentNode) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException {
                  doCreateChildNode(parentNode, 1);
              }
              
              private void doCreateChildNode(Node parentNode, int level) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException {
                  if (level == 5)
                      return;
                  
                  for (int i = 0; i < 1; ++i) {
                      Node child = parentNode.addNode("child-" + level + "-" + i);
                      for (int j = 0; j < 10; ++j)
                          child.setProperty("p" + j, "property" + j);
                      
                      doCreateChildNode(child, level + 1);
                  }
              }
      

      After calling createMultipleNodes, then make a simple query "SELECT * FROM [pd:product]", the expected result should be ten rows, but actual result is not (can be any random number between 12 ~ 16 in my test)

      Attachments

        1. jprofiler_mode_1822.zip
          329 kB
        2. no-transaction.nps
          37 kB
        3. no-transaction.png
          no-transaction.png
          103 kB
        4. transaction.nps
          39 kB
        5. transaction.png
          transaction.png
          99 kB

        Issue Links

          Activity

            People

              rhauch Randall Hauch (Inactive)
              ozhou_jira Oliver Zhou (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: