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] Add examples for reuse ID policy #4237

Closed
wants to merge 7 commits into from

Conversation

hhunter-ms
Copy link
Collaborator

Description

Add examples provided by @kaibocai for workflow reuse Id policy

Issue reference

PR will close: #3909

Signed-off-by: Hannah Hunter <[email protected]>
@hhunter-ms hhunter-ms self-assigned this Jun 26, 2024
@hhunter-ms hhunter-ms requested review from a team as code owners June 26, 2024 16:00
@kaibocai
Copy link
Contributor

The examples look good to me, wondering if we should also add an example for the default behavior which will error out when reuse the workflow ID.

Copy link
Member

@msfussell msfussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaibocai Left some comments and questions.

Only one workflow instance with a given ID can exist at any given time. However, if a workflow instance completes or fails, its ID can be reused by a new workflow instance. Note, however, that the new workflow instance effectively replaces the old one in the configured state store.
#### Reusing workflow identities

If a workflow instance completes or fails, its ID can be reused by a new workflow instance. The new workflow instance effectively replaces the old one in the configured state store.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear here, you can set a policy called "api.REUSE_ID_ACTION_TERMINATE" that does force an existing workflow to terminate so you can start a new workflow with the same id.

Is this correct? Little unclear here in the wording. If so, then it would also be good to have a list of the reuse ID policies somewhere in the docs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that's correct

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaibocai - Can you then provide a list of the api.REUSE_ID_ACTION_XX values and what each one does in a table?

}
// Wait for orchestration to start...
client.WaitForOrchestrationStart(ctx, id)
// Schedule the workflow again using the same id. However it will ignore creating the new orchestration, since the id is already in use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean "ignore". You mean nothing happens (which is strange), or it will eventually get rescheduled. A silent failure event would be really hard to determine. We need to be clearer here on what happens IMO. Can you explain this more and why I would choose this option?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaibocai - See my questions. It would help to clarify clearly when these actions are used.
Action: api.REUSE_ID_ACTION_IGNORE

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean "ignore". You mean nothing happens (which is strange), or it will eventually get rescheduled. A silent failure event would be really hard to determine. We need to be clearer here on what happens IMO. Can you explain this more and why I would choose this option?

@kaibocai an explanation of this would help me as well!

Copy link
Contributor

@kaibocai kaibocai Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so when you want to start an orchestration but only when it's not in running, then you can use this option. More discussion details can be found microsoft/durabletask-go#42

Copy link
Member

@msfussell msfussell Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaibocai - Ok, but this is a discussion and there is no final conclusion here of what was actually implemented. We need a table for the reuse ID options and what each one does. Can you add this?

Copy link

github-actions bot commented Jul 4, 2024

Stale PR, paging all reviewers

@github-actions github-actions bot added the stale label Jul 4, 2024
@hhunter-ms hhunter-ms removed the stale label Jul 8, 2024
@hhunter-ms
Copy link
Collaborator Author

@cgillum do you mind taking a look as well? I'm hoping to represent this well in the docs and I feel like I'm not being as clear as I could be.

```go
func main() {
r := task.NewTaskRegistry()
r.AddOrchestratorN("SingleActivity", func(ctx *task.OrchestrationContext) (any, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code sample is for the Durable Task SDK. We should instead provide a code sample for Dapr Workflow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please rework this code to use Workflow and keep this as simple as needed. I suggest having this in at least 2 languages also so that this is open to more developers to understand (at least one of .NET or Java

ctx := context.Background()
client, engine := startEngine(ctx, r)

instanceID := api.InstanceID("IGNORE_IF_RUNNING_OR_COMPLETED")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string value here is intended to be the workflow ID, which is typically some business identity or is random (in which case we don't use it at all). It looks like we're trying to specify a policy as a workflow ID, which is a bit confusing. I think it would be better to not specify an explicit workflow ID at all to avoid confusion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this code all need to change to workflow example, this can be changed at the same time.

Copy link
Member

@msfussell msfussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaibocai - This is important information. Can you update this PR, with workflow examples and a description of the "why" for each of the policies? Thanks

```go
func main() {
r := task.NewTaskRegistry()
r.AddOrchestratorN("SingleActivity", func(ctx *task.OrchestrationContext) (any, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please rework this code to use Workflow and keep this as simple as needed. I suggest having this in at least 2 languages also so that this is open to more developers to understand (at least one of .NET or Java

ctx := context.Background()
client, engine := startEngine(ctx, r)

instanceID := api.InstanceID("IGNORE_IF_RUNNING_OR_COMPLETED")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this code all need to change to workflow example, this can be changed at the same time.


You can use the following policies to reuse workflow IDs:

| Policies | Description |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there are only two Workflow reuse ID policies? What is the default if not set?

Why would use REUSE_ID_ACTION_IGNORE? This just means that a new workflow can never be started if there is an existing one already?

@msfussell msfussell added the P0 label Jul 9, 2024
@msfussell msfussell added this to the 1.14 milestone Jul 9, 2024
Copy link

Stale PR, paging all reviewers

@hhunter-ms
Copy link
Collaborator Author

Closing for now as this is not supported in any SDK at the moment.

@hhunter-ms hhunter-ms closed this Jul 16, 2024
@hhunter-ms hhunter-ms modified the milestones: 1.14, 1.15 Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example for workflow ID reuse policy
4 participants