Resetting the workflow with different event Id

INVALID_ARGUMENT: nDCStateRebuilder unable to rebuild mutable state to event ID: 11, version: 0, this event must be at the boundary

I am trying to reset the workflow ,if I pass EventId as EVENT_TYPE_WORKFLOW_TASK_STARTED .It is working but the workflow is executed from the start . My use case is to reset the workflow after n activities execution .Now, when I change the EventId to any other enum ( EVENT_TYPE_ACTIVITY_TASK_COMPLETED ,EVENT_TYPE_ACTIVITY_TASK_STARTED) ,it is throwing error stating nDCStateRebuilder unable to rebuild mutable state to event ID: 11, version: 0, this event must be at the boundary. I have updated the temporal-sdk ,it is still not working

Hello @aditi_ritam ,

I think the event_id can only be one of the following, https://docs.temporal.io/tctl-next/modifiers#--event-id

Specify the eventId of any event after WorkflowTaskStarted to which you want to reset. Valid values are WorkflowTaskCompleted, WorkflowTaskFailed, and WorkflowTaskTimeout.

So if you want to reset the workflow before an activity you can set the event_id to the previous workflowTaskCompleted. You might also want to have a look at the https://docs.temporal.io/tctl-next/modifiers#--reset-type option.

Can I ask, what is your use case to reset the workflow?

Regards,
Antonio

I dont want to execute the workflow from the start .I want to start the reset the workflow from few activities.EVENT_TYPE_WORKFLOW_TASK_STARTED is starting the workflow from the start , which restarting the workflow from the start and activities are executed twice.

You can specify a reset event id. If you look at your workflow history in web ui for example, the event types that you want to reset to is WorkflowTaskStarted. So if you had wf event history:

1. WorkflowExecutionStarted
2. WorkflowTaskScheduled
3.WorkflowTaskStarted
4. WorkflowTaskCompleted
5. ActivityTaskScheduled (for activity A)
6. ActivityTaskStarted
7. ActivityTaskCompleted
8. WorkflowTaskScheduled
9. WorkflowTaskStarted
10. WorkflowTaskCompleted
11. ActivityTaskScheduled (for activity B)
12. ActivityTaskStarted
13. ActivityTaskCompleted
.....

To reset after activity A invocation and before activity B invocation you can set the value of reset event id to 9.

If you share your workflow history (json) and tell us after what activity you want to reset to we can to find out the reset event id for your use case.

1 Like