Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-3579

InternalVersionImpl.internalDetachPredecessor() and internalDetachSuccessor() do not check for duplicates when updating jcr:successors / jcr:predecessors

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.2.13, 2.4.3, 2.6
    • None
    • versioning
    • None

    Description

      We are using Jackrabbit 2.2.x branch (although the issue seems the same with 2.4.x and 2.6 so far I see).

      We have a maintenance job that runs periodically and purges the old unused versions of nodes to keep the versioning store and index in boundaries.
      The Job is using Jackrabbit Versioning API to remove versions.

      The org.apache.jackrabbit.core.version.InternalVersionHistoryImpl.removeVersion(Name) has the call to detaching the removed version from the version graph:

      // detach from the version graph
      v.internalDetach();

      which in turn calls InternalVersionImpl.internalDetachPredecessor() and internalDetachSuccessor() methods to update predecessors and successor.

      Those two methods are using List to calculate new values and store them in corresponding jcr:successors or jcr:predecessors properties.

      The only thing is there is no check for duplicates in those lists, so with the time we see that jcr:successors and jcr:predecessors have duplicates (and they are growing with each version removal ). See attached screenshot.

      From my feeling the internalDetachPredecessor() and internalDetachSuccessor() should rather use HashSet (or if the order is important a LinkedHashSet) instead of List to prevent storing duplicates.

      Attachments

        1. InternalVersionImpl.patch
          3 kB
          Sergiy Shyrkov
        2. RemoveVersionTest.patch
          4 kB
          Sergiy Shyrkov
        3. test-case-version-graph.jpg
          29 kB
          Sergiy Shyrkov
        4. screenshot-1.jpg
          112 kB
          Sergiy Shyrkov

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            shyrkov Sergiy Shyrkov

            Dates

              Created:
              Updated:

              Slack

                Issue deployment