Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Terminate Running workflow using ACS AEM Commons Workflow Instance Remover

Avatar

Level 4

Sometimes our authors upload 2k-4k images at a time, which triggers multiple workflows through launchers, as these instances are very high in number, many times they get stuck and the image is unable to be processed. 

 

I am trying to use the ACS AEM Commons’ Workflow Instance Remover, to schedule it to run every hour, and delete the workflow instances if it's in a running state from the last 60 mins. It is working fine, and all the stuck workflow instances are getting deleted. 

ashish_mishra1_1-1657994129819.png

 

However, the assets still show an "In Workflow" message, even though the workflow instance is removed from /var/workflow/instance folder.

 

ashish_mishra1_0-1657994004746.png

 

How can we fix it?

 

@arunpatidar @Bhuwan_B @SantoshSai 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @ashish_mishra1,

If you will look into card implementation (it can be found on crx under /libs/dam/gui/coral/components/admin/contentrenderer/card/common/card-banner.jsp), you will see that In Workflow... status is shown base on information from WorkflowStatus object and method isRunningWorkflow.

isRunningWorkflow method is using PaylodMap underneath which is using com.adobe.granite.workflow.core.PayloadMapCache.

Most likely after removing workflow instance by ACS Commons Instance Remover tool, above cache has not been refreshed. In other words it still includes information about workflow instances that has been removed.

Luckily this is in memory cache. You can try one of below options to remove outdated information from that cache.

  • Restart AEM instance
  • Restart Adobe Granite Workflow Core bundle - to do this, navigate to /system/console/bundles, find Adobe Granite Workflow Core bundle, stop and start it again
  • Restart com.adobe.granite.workflow.core.PayloadMapCache component - simply go to /system/console/components find com.adobe.granite.workflow.core.PayloadMapCache - stop this component and run it again
  • If you have Groovy Console you can run below script
    import com.adobe.granite.workflow.PayloadMap
    
    CLEAR_CACHE = false
    
    PayloadMap pm = resourceResolver.adaptTo(PayloadMap.class)
    
    // getting all entries from cache
    pm?.payloadMapCache?.cache?.each {payloadPath, wfInstance ->
        println "$payloadPath, $wfInstance"
    }
    
    // checking if cache is initilized and setting proper value that will allow to refresh it
    if (pm?.payloadMapCache?.isInitialized && CLEAR_CACHE) {
        pm?.payloadMapCache?.isInitialized = false
        
        // clearing the cache
        pm?.payloadMapCache?.cache?.clear()
        
        // initializing the cache
        pm?.payloadMapCache?.init()
        
        println "Workflow payload cache has been initialized"
    }
    In case you would like to clear the cache, please set CLEAR_CACHE variable in above script to true. In other case script will only return list of all items included in the cache.
    Above script can also be used at first place to confirm that PayloadMapCache is root cause of your issue. Run the script, and if in results you will see path(s) to the assets that should not be there - this is it.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @ashish_mishra1,

If you will look into card implementation (it can be found on crx under /libs/dam/gui/coral/components/admin/contentrenderer/card/common/card-banner.jsp), you will see that In Workflow... status is shown base on information from WorkflowStatus object and method isRunningWorkflow.

isRunningWorkflow method is using PaylodMap underneath which is using com.adobe.granite.workflow.core.PayloadMapCache.

Most likely after removing workflow instance by ACS Commons Instance Remover tool, above cache has not been refreshed. In other words it still includes information about workflow instances that has been removed.

Luckily this is in memory cache. You can try one of below options to remove outdated information from that cache.

  • Restart AEM instance
  • Restart Adobe Granite Workflow Core bundle - to do this, navigate to /system/console/bundles, find Adobe Granite Workflow Core bundle, stop and start it again
  • Restart com.adobe.granite.workflow.core.PayloadMapCache component - simply go to /system/console/components find com.adobe.granite.workflow.core.PayloadMapCache - stop this component and run it again
  • If you have Groovy Console you can run below script
    import com.adobe.granite.workflow.PayloadMap
    
    CLEAR_CACHE = false
    
    PayloadMap pm = resourceResolver.adaptTo(PayloadMap.class)
    
    // getting all entries from cache
    pm?.payloadMapCache?.cache?.each {payloadPath, wfInstance ->
        println "$payloadPath, $wfInstance"
    }
    
    // checking if cache is initilized and setting proper value that will allow to refresh it
    if (pm?.payloadMapCache?.isInitialized && CLEAR_CACHE) {
        pm?.payloadMapCache?.isInitialized = false
        
        // clearing the cache
        pm?.payloadMapCache?.cache?.clear()
        
        // initializing the cache
        pm?.payloadMapCache?.init()
        
        println "Workflow payload cache has been initialized"
    }
    In case you would like to clear the cache, please set CLEAR_CACHE variable in above script to true. In other case script will only return list of all items included in the cache.
    Above script can also be used at first place to confirm that PayloadMapCache is root cause of your issue. Run the script, and if in results you will see path(s) to the assets that should not be there - this is it.

Avatar

Level 5

Hi @lukasz-m ,

We are using workflow remover to purge the running workflows. But, we are not able author the tool. Is there any configuration that needs to be done "ACS AEM Commons’ Workflow Instance Remover"?

AEM Version - Cloud Service

How to configure ACS AEM Commons’ Workflow Instance Remover and author workflow remover?

 

Screenshot (59).png

 

@thanikon