Hi,
I’m trying to build a feature in my api to restart failed/ended workflows. I’ve noticed that doing so with cron jobs does not work, whereas other workflows can be restarted.
The following is my reset code:
public String resetWorkflowExecution(String workflowId, String terminationReason) {
WorkflowStub workflowStub = client.newUntypedWorkflowStub(workflowId, Optional.empty(), Optional.empty());
WorkflowExecution execution = workflowStub.getExecution();
ResetWorkflowExecutionRequest request = ResetWorkflowExecutionRequest.newBuilder()
.setNamespace("default")
.setReason(terminationReason)
.setRequestId(UUID.randomUUID().toString())
.setWorkflowExecution(execution)
.setWorkflowTaskFinishEventId(4)
.build();
ResetWorkflowExecutionResponse response = client.getWorkflowServiceStubs().blockingStub().resetWorkflowExecution(request);
return "reset id: " + response.getRunId();
}
and here is the error I get when restarting terminated and time out workflows:
"status": 500,
"error": "Internal Server Error",
"trace": "io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Workflow task finish ID must be > 1 && <= workflow last event ID.\r\n\tat io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)\r\n\tat io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)\r\n\tat io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)\r\n\tat io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.resetWorkflowExecution(WorkflowServiceGrpc.java:3015)
and this goes on and on. I see in the code where the error occurs, but I’m unsure how to fix this. I’m having trouble understanding what setWorkflowTaskFinishEventId does.
Another note: this error is not given when restarting a canceled workflow. My success message is sent, but it fails to restart. It just cancels/fails again.
Any help is appreciated. Thanks