Expand my Community achievements bar.

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

Avatar

Level 1

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!

6 Replies

Avatar

Community Advisor

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

Avatar

Community Advisor

Hi @lavanya-merkle 

 

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

 

Thanks

Narendra

Avatar

Community Advisor

@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

Avatar

Level 5

@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.

Avatar

Community Advisor

Hi @lavanya-merkle 

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



Arun Patidar

Avatar

Level 4

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.

Screenshot 2025-02-24 at 13.11.01.png

 

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.