FixBpmPackages Patch is not optimized for big instances with millions of Bpm packages.
We have seen similar behaviors on:
Steps to reproduce
create an environment on Alfresco 3.3.5 with 1M documents and 1M workflows (one per doc)
Upgrade the environment to Alfresco 4.1.4
Expected behavior patch should complete on a feasible time.
Observed behavior the upgrade process takes many hours to complete.
A customer is reporting that this patch takes several DAYS to complete on their instance, they have 3M Bpm packages.
Their solution: pumping up the max number in cache for the needed objects and following the approach you used in other Patches implementations, using BatchProcessor in order to take advantage of our multiprocessor
I don't know if this can be considered a bug of Enhancement.