Infinite Loop

When designing your workflow it is possible to add workflow steps in such a way that it causes an infinite loop at runtime.

In most cases these infinite loops occur due to incorrect design, where steps loop back on to themselves without going through an asynchronous step (like a Task step, or a SmartObject step in which you've enabled the "Wait for an external system" option). In other cases, a step may trigger an external event that the workflow listens for to start new workflow instances and thus causes an infinite recursive loop of workflow instances. You can resolve infinite loop warnings by moving the steps around or by adding different paths for the workflow to follow.

In some cases, however, your workflow design might warn you about an infinite loop but the loop logic that you've configured is completely valid. In these cases, you can safely ignore the warning and deploy your workflow.

An infinite loop can cause the server to become unresponsive. Because of this, when an infinite loop is detected in your workflow design, you will see a yellow warning indicator on the step and a corresponding warning message in the error console. Additionally, you will see a general warning beneath the deployment button. Warning indicators never prevent you from deploying your workflow.

Here are some points to consider when you see this warning:

  • Determine if a Task step should be inserted between two steps that loop, such as a Rework task for the Originator.
  • Insert a SmartObject step that waits for an external event. For more context see Example - Infinite Loop with a SmartObject step.
  • Reconfigure your workflow so that it doesn't need to loop but rather flows into an End step or back to a Task step instead.
  • If you decide that your workflow logic is sound, it is recommended that you run a few test scenarios to make sure your workflow instances complete as expected and do not infinitely loop.
To help protect your K2 environment from runaway workflow instances, administrators can set Workflow Step Instances Threshold policies that will force workflows to go into an Error state if too many instances of a step occurred in a specified amount of time. See the Settings topic for more information about setting these policies.

Use the following examples for determining if you need to redesign your workflow or you can safely ignore the infinite loop warning.