private WorkflowModel findLastFailedSubWorkflowIfAny(
            TaskModel task, WorkflowModel parentWorkflow) {
        if (TaskType.TASK_TYPE_SUB_WORKFLOW.equals(task.getTaskType())
                && UNSUCCESSFUL_TERMINAL_TASK.test(task)) {
            WorkflowModel subWorkflow =
                    executionDAOFacade.getWorkflowModel(task.getSubWorkflowId(), true);
            Optional<TaskModel> taskToRetry =
                    subWorkflow.getTasks().stream().filter(UNSUCCESSFUL_TERMINAL_TASK).findFirst();
            if (taskToRetry.isPresent()) {
                return findLastFailedSubWorkflowIfAny(taskToRetry.get(), subWorkflow);
            }
        }
        return parentWorkflow;
    }
Gets the last instance of each failed task and reschedule each Gets all cancelled tasks and
schedule all of them except JOIN (join should change status to INPROGRESS) Switch workflow
back to RUNNING status and call decider.

@param workflowId the id of the workflow to be retried
core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java