# Resuming a failed workflow from the point of failure

**URL:** <https://community.temporal.io/t/resuming-a-failed-workflow-from-the-point-of-failure/7109>\
**Category:** Community Support\
**Tags:** java-sdk, mysql, retries\
**Created:** [January 31, 2023, 3:36pm UTC](https://community.temporal.io/t/resuming-a-failed-workflow-from-the-point-of-failure/7109 "2023-01-31T15:36:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Siddharth\_Saxena](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/siddharth_saxena/32/3239_2.png) [@Siddharth\_Saxena](https://community.temporal.io/u/Siddharth_Saxena)\
**Post date:** [January 31, 2023, 3:36pm UTC](https://community.temporal.io/t/resuming-a-failed-workflow-from-the-point-of-failure/7109/1 "2023-01-31T15:36:28Z")

</div>

Hi team, I am a newbie. Would someone please help me understand if my workflow has 7 steps (activities). Workflow got failed while executing 5th one.  
How do I resume my workflow from the same point of failure.  
Please help me with java code example.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [January 31, 2023, 7:13pm UTC](https://community.temporal.io/t/resuming-a-failed-workflow-from-the-point-of-failure/7109/2 "2023-01-31T19:13:17Z")

</div>

The simplest approach is to not fail the workflow on activity failure. Just keep retrying the activity until it is fixed.

If you really need to restart the failed workflow you use the [reset](https://docs.temporal.io/workflows#reset) feature.

---

<div class="post-metadata">

**Author:** ![Siddharth\_Saxena](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/siddharth_saxena/32/3239_2.png) [@Siddharth\_Saxena](https://community.temporal.io/u/Siddharth_Saxena)\
**Post date:** [February 1, 2023, 6:46am UTC](https://community.temporal.io/t/resuming-a-failed-workflow-from-the-point-of-failure/7109/3 "2023-02-01T06:46:34Z")

</div>

I have gone through some other tickets. Found this way to restart the workflow from the point of failure.  
Let me know if I am doing it correctly 🙂

RESET WORKFLOW USING THE SAME WORKFLOW ID :

ResetWorkflowExecutionRequest request = ResetWorkflowExecutionRequest.newBuilder().setNamespace(namespace)  
.setWorkflowExecution(WorkflowExecution.newBuilder().setWorkflowId(workflowId).build())  
.setWorkflowTaskFinishEventId(tid)  
.setReason(“reset”)  
.build();

CODE TO FIND THE HISTORY OF EVENTS OF A WORKFLOW :

```
WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();

GetWorkflowExecutionHistoryResponse result =
    service
        .blockingStub()
        .getWorkflowExecutionHistory(
            GetWorkflowExecutionHistoryRequest.newBuilder()
                .setNamespace(namespace)
                .setExecution(WorkflowExecution.newBuilder().setWorkflowId(workflowId).build())
                .build());

```

CODE TO FIND THE LAST SUCCESSFUL EVENTID :

for (HistoryEvent e : history.getEventsList()){  
//TODO : paginated history events list  
if(e.getEventType() == EventType.EVENT\_TYPE\_ACTIVITY\_TASK\_FAILED)  
break;  
if(e.getEventType() == EventType.EVENT\_TYPE\_WORKFLOW\_TASK\_STARTED)  
tid = e.getEventId();  
}

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [February 1, 2023, 2:22pm UTC](https://community.temporal.io/t/resuming-a-failed-workflow-from-the-point-of-failure/7109/4 "2023-02-01T14:22:51Z")

</div>

For use case I think you are looking to find the last completed workflow task as the reset point. Could reference how tctl does it [here](https://github.com/temporalio/tctl/blob/main/cli/workflow_commands.go#L1225), its Go code but think easy to read to get idea.

---

<div class="post-metadata">

**Author:** ![Haiping\_Yu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/haiping_yu/32/3256_2.png) [@Haiping\_Yu](https://community.temporal.io/u/Haiping_Yu)\
**Post date:** [February 3, 2023, 2:01am UTC](https://community.temporal.io/t/resuming-a-failed-workflow-from-the-point-of-failure/7109/5 "2023-02-03T02:01:30Z")

</div>

I tried the code but got the error:

```auto
io.temporal.failure.ActivityFailure: scheduledEventId=35, startedEventId=36, activityType='WaitJenkins', activityId='3fea59fa-d703-39d5-8612-4491a62f2ac7', identity='1@zcp-console-dev-main-va1-meta-5f4f5fb684-q7cqs', retryState=RETRY_STATE_NON_RETRYABLE_FAILURE

```

So how can I retry if the activity state is RETRY\_STATE\_NON\_RETRYABLE\_FAILURE

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [February 3, 2023, 2:29pm UTC](https://community.temporal.io/t/resuming-a-failed-workflow-from-the-point-of-failure/7109/6 "2023-02-03T14:29:42Z")

</div>

Could you give more info please? Assume you did reset to a workflow task before “WaitJenkins” activity and it failed on the new created execution? Is your activity throwing a non-retryable error from its code?

---

<div class="post-metadata">

**Author:** ![Haiping\_Yu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/haiping_yu/32/3256_2.png) [@Haiping\_Yu](https://community.temporal.io/u/Haiping_Yu)\
**Post date:** [February 7, 2023, 3:29am UTC](https://community.temporal.io/t/resuming-a-failed-workflow-from-the-point-of-failure/7109/7 "2023-02-07T03:29:49Z")

</div>

yes, the activity threw a non-retryable error.

So the reset method won’t reset this error right?
