Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-14187

Remove orphan versions after a recursive delete

    XMLWordPrintable

    Details

      Description

      How it should work

      When deleting a Document, the async listener OrphanVersionRemoverListener will run and according to VersionRemovalPolicy this listener may remove the orphan versions if they are not filtered by a contributed OrphanVersionRemovalFilter.

      Why it fails for recursive delete

      For recursive deletes (i.e. folder delete with children) only the first level of deletion is handled at application level, the subtree recursion is handled at SQL level using a ON DELETE CASCADE trigger.

      Because versions don't have a parentId (unfiled), they are not deleted by the trigger.

      Problems

      Handling configurable logic at SQL level is not possible.
      On the other hand, managing the recursion at Java level is far more costly.

      Quick solution

      A quick solution is to provide a cleanup stored procedure and use a scheduler to run it periodically.

      Target solution

      If we want to keep the same configurability, we may need to do all the recursive delete at java level (NXP-21460). Doing that may also help us fixing NXP-14075.


      Implemented solution

      The solution chosen to solve this issue is to add a scheduled cleanup mechanism. The cleanup mechanism does periodic commits, every 1000 documents by default. This value can be changed using the Configuration Property org.nuxeo.orphanVersionsCleanup.commitSize.

      In hotfixes version for Nuxeo 8.10 and Nuxeo 7.10, it's not enabled by default, and must be enabled by an explicit contribution:

        <extension target="org.nuxeo.ecm.core.scheduler.SchedulerService" point="schedule">
          <schedule id="orphanVersionsCleanup">
            <!-- cleanup every day at 1:30 AM -->
            <cronExpression>0 30 1 * * ?</cronExpression>
            <event>orphanVersionsCleanup</event>
          </schedule>
        </extension>
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                4 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 days
                  2d