Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workflow] Support for workflow ID reuse policies #7101

Closed
cgillum opened this issue Oct 26, 2023 · 4 comments · Fixed by #7308
Closed

[Workflow] Support for workflow ID reuse policies #7101

cgillum opened this issue Oct 26, 2023 · 4 comments · Fixed by #7308
Assignees
Milestone

Comments

@cgillum
Copy link
Contributor

cgillum commented Oct 26, 2023

In what area(s)?

/area runtime

Describe the feature

This is a continuation of a discussion here. The idea is simplify the creation and re-creation of workflows that have a well-known workflow ID.

When scheduling the creation of a new workflow instance, the following options should be available (taken from the proposal by @clintsinger):

  • TerminateIfExists - Terminates any existing workflows with the same instance ID and then schedules a new instance as one atomic action, similar to on-demand ContinueAsNew.
  • SkipIfExists - If there is an existing workflow already scheduled, then the scheduler does nothing.
  • ThrowIfExists - If there is an existing workflow then the scheduler throws an exception (this is the current behavior).

As an optional extension of this, we can consider exposing an "Execution ID" or "Generation ID" property to the workflow which can help distinguish different instantiations of the given workflow instance ID. The Durable Task Framework has this concept already (it's an auto-generated UUID) but we don't currently surface it anywhere.

Release Note

RELEASE NOTE: ADD Workflow creation policy options.

@olitomlinson
Copy link

While we're on the subject of scheduling workflows, @cgillum I raised some feedback a while back that it would be useful to improve the DevEx for the scenario when trying to start a workflow when that workflow is already running.

Right now, it throws an Exception, Ideally i'd prefer it not to throw, as it's not necessarily an exceptional circumstance, it's entirely use-case specific.

However, in the spirit of being pragmatic, if an Exception must remain, it would be nice to have it throw a specific exception, rather than relying on matching a vague/ambiguous string prefix, which could change!

this is what I do right now :

try
{
    result = await workflowClient.ScheduleNewWorkflowAsync(
        name: nameof(SagaWorkflow),
        instanceId: workflowId,
        input: orderInfo);
}
catch(Grpc.Core.RpcException ex) when (ex.StatusCode == Grpc.Core.StatusCode.Unknown && ex.Status.Detail.StartsWith("an active workflow with ID"))
{
    ...
}

@cgillum
Copy link
Contributor Author

cgillum commented Oct 26, 2023

Based on the proposal above, this would come into play only when using the (default) ThrowIfExists policy. I agree that we need to have a better exception handling story than this.

@rabollin
Copy link
Contributor

rabollin commented Nov 8, 2023

/assign

@kaibocai
Copy link
Contributor

kaibocai commented Dec 13, 2023

Working items for reuse ID support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants