Workflow Instance Stuck in Infinite Execution - Not Terminating After Bundle and Instance Restart | Community
Skip to main content
February 20, 2025
Solved

Workflow Instance Stuck in Infinite Execution - Not Terminating After Bundle and Instance Restart

  • February 20, 2025
  • 7 replies
  • 1680 views

Hello AEM community,

 

I'm encountering an issue where a workflow instance keeps running even after I restart the bundle in AEM. I've tried various troubleshooting steps like terminating the instance, purging active instances, and restarting the AEM instance itself, but none of these actions seem to resolve the problem. Interestingly, the issue is temporarily fixed after a full machine restart and setting up AEM again, but it eventually recurs.

 

Has anyone else faced this problem before? What steps or solutions have you used to resolve this issue permanently?

Any help or suggestions would be greatly appreciated!

 

Thanks in advance!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Shiv_Prakash_Patel

Hi @lavanya-merkle ,

There could be multiple reason for active workflows

1. Workflow session is not properly closed in a custom workflow process step, it may cause an infinite loop.

Solution: Ensure that all session.logout() and resourceResolver.close() calls are properly executed

2. If you have any custom event listeners in your OSGi services that might be triggering workflow executions.

Solution: Disable them temporarily and see if the issue persists.

3. Even after terminating the workflow, some instances might not be properly removed from the repository.

Solution: Purge old/completed workflow instances. Also go to crx/de (/var/workflow/instances) and delete any stuck or old workflow instances manually.

4. If the workflow execution is stuck due to a process step failing, it may cause the instance to keep running indefinitely.

Solution: Checking for any workflows in a RUNNING state, and manually forcing completion.

Regards,

7 replies

Shiv_Prakash_Patel
Community Advisor
Shiv_Prakash_PatelCommunity AdvisorAccepted solution
Community Advisor
February 20, 2025

Hi @lavanya-merkle ,

There could be multiple reason for active workflows

1. Workflow session is not properly closed in a custom workflow process step, it may cause an infinite loop.

Solution: Ensure that all session.logout() and resourceResolver.close() calls are properly executed

2. If you have any custom event listeners in your OSGi services that might be triggering workflow executions.

Solution: Disable them temporarily and see if the issue persists.

3. Even after terminating the workflow, some instances might not be properly removed from the repository.

Solution: Purge old/completed workflow instances. Also go to crx/de (/var/workflow/instances) and delete any stuck or old workflow instances manually.

4. If the workflow execution is stuck due to a process step failing, it may cause the instance to keep running indefinitely.

Solution: Checking for any workflows in a RUNNING state, and manually forcing completion.

Regards,

Shiv Prakash
narendragandhi
Community Advisor
Community Advisor
February 20, 2025

Hi @lavanya-merkle 

 

Can you check your workflow launcher configuration as well.  You may have a condition to trigger that workflow.

 

Thanks

Narendra

aanchal-sikka
Community Advisor
Community Advisor
February 20, 2025

@lavanya-merkle 

  • If the Workflow Instance ID the same all through?
  • Are you noticing any errors when you try to terminate the instance?
  • Anything else that this workflow instance is writing to logs?
Aanchal Sikka
Uppari_Ramesh
February 20, 2025

@lavanya-merkle The most probable reason for workflow stuck in infinite execution is, there could be an exception somewhere in the code(in workflow or service/util referred in workflow). Particularly in workflows, if any exception occurs, then it will go to the try block and it will keep retrying the same code again and it will end up with same exception and repeats same again.

1. Open error.log and see at which line the exception is thrown and handle it properly.

2. Use finally block to prevent the re-execution.

3. If you want to terminate the instance, you can identify the workflow in instances and in /var/workflow/instances and you can delete manually.

 

Thanks,

Ramesh.

 

Thanks,

Ramesh.

arunpatidar
Community Advisor
Community Advisor
February 21, 2025

Hi @lavanya-merkle 

Please check the workflow queue, it might be possible that queue is blocked due to bundle restart.

Arun Patidar
giuseppebaglio
New Member
February 24, 2025

Deleting stuck workflows in AEM from CRXDE involves several steps to ensure that you safely remove the workflow instances without causing inconsistencies in your system.


 

Manual Deletion via CRXDE:

  • Always create a backup before making changes.
  • Manually delete the nodes representing stuck workflows under /apps/workflow/instances/; Ensure you only delete the specific instances that are stuck and not active or needed workflows.
  • If you delete a parent node (e.g., a server sling folder), you may need to recreate it with the correct properties to maintain system functionality.
  • After deletion, trigger a new workflow to ensure that the system is functioning correctly.

Important Notes

  • If you encounter performance issues during deletion, consider stopping incremental reindexing temporarily.
  • Always ensure you have a recent backup before making significant changes.

  • Be cautious when deleting workflows to avoid removing active or necessary instances.

 

kautuk_sahni
Community Manager
Community Manager
March 4, 2025

@lavanya-merkle Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Kautuk Sahni