workflow-core icon indicating copy to clipboard operation
workflow-core copied to clipboard

How to retry a workflow, of which one step failed?

Open DemetriouJohn opened this issue 4 years ago • 6 comments

Occasionally, a step may fail because of network connectivity or any issue. I do not see anywhere in the docs a possibility to restart the workflow from the step it failed during its previous run.

Resume workflow only resumes previously suspended workflows.

DemetriouJohn avatar May 14 '21 06:05 DemetriouJohn

You can configure a step to have retry behavior - https://workflow-core.readthedocs.io/en/latest/error-handling/

danielgerlag avatar May 14 '21 13:05 danielgerlag

Maybe I was not clear enough in my question. What I meant was, How can I resume a previous failed workflow, on a later time, on demand. e.g step 5 of a 10 step workflow failed due to remote server issues. Remote server is fixed 2 hours later, Resume previously failed workflow, starting from failed step.

Similar logic to a Suspended workflow, only this one has failed and the step that has failed, needs to re-run

DemetriouJohn avatar May 14 '21 13:05 DemetriouJohn

Should you be terminating the workflow if you intend to retry it later?

danielgerlag avatar May 14 '21 13:05 danielgerlag

How would you suggest to handle this?

DemetriouJohn avatar May 14 '21 14:05 DemetriouJohn

You can set the default error behavior per workflow.

public void Build(IWorkflowBuilder<object> builder)
{
    builder                
        .UseDefaultErrorBehavior(WorkflowErrorHandling.Suspend)
        .StartWith<HelloWorld>()                
        .Then<GoodbyeWorld>();
}

or per step

public void Build(IWorkflowBuilder<object> builder)
{
    builder                
        .StartWith<HelloWorld>()                
        .Then<GoodbyeWorld>()
            .OnError(WorkflowErrorHandling.Suspend);
}

danielgerlag avatar May 15 '21 21:05 danielgerlag

This is mostly working so far, but quite often, some workflows, even though they are set to suspend on error, they actually fail instead.

DemetriouJohn avatar Sep 01 '21 06:09 DemetriouJohn