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

[Workflows] Events of the same name are not buffered #6799

Closed
olitomlinson opened this issue Aug 11, 2023 · 9 comments
Closed

[Workflows] Events of the same name are not buffered #6799

olitomlinson opened this issue Aug 11, 2023 · 9 comments
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@olitomlinson
Copy link

olitomlinson commented Aug 11, 2023

cc @cgillum

Let's say a workflow implements a simple monitor pattern that awaits on the same external event name ("my-external-event") indefinitely.

public override async Task<bool> RunAsync(WorkflowContext context, List<string> input)
{
    var externalEvent = await context.WaitForExternalEventAsync<string>("my-external-event");

    input.Add(externalEvent);
    context.SetCustomStatus(string.Concat(input.ToArray()));
    context.ContinueAsNew(input);
    return true;
}

Actual behaviour

If several events (named "my-external-event") are raised in quick succession or in parrallel to the awaiting workflow, only the first event is consumed by the awaiting workflow, all the other events are dropped, and are therefor not allocated on subsequent generations of the monitor loop.

Expected behaviour

If several events (named "my-external-event") are raised in quick succession or in parallel to the awaiting workflow, all the events will be buffered (up to some configurable user-defined max limit) and each iteration of the monitor loop will consume one of the buffered messages (via context.WaitForExternalEventAsync()), ideally in a FIFO order)

Note : preserveUnprocessedEvents: true does not produce the expected behaviour, despite it sounding like it should.

If set to true, re-adds any unprocessed external events into the new execution history when the workflow instance restarts. If false, any unprocessed external events will be discarded when the workflow instance restarts.

@olitomlinson olitomlinson added the kind/bug Something isn't working label Aug 11, 2023
@cgillum
Copy link
Contributor

cgillum commented Aug 18, 2023

The behavior you're looking for is supposed to be handled by preserveUnprocessedEvents: true. What are you observing when this is set?

@olitomlinson
Copy link
Author

@cgillum preserveUnprocessedEvents: true has no impact it seems.

@olitomlinson
Copy link
Author

Potentially related to dapr/dotnet-sdk#1129

@cgillum
Copy link
Contributor

cgillum commented Aug 22, 2023

@nyemade-uversky let's add this to the tracking board for workflows. This functionality is important for developers leveraging the monitor pattern.

@olitomlinson
Copy link
Author

@nyemade-uversky bump

@mukundansundar
Copy link
Contributor

/assign

@mukundansundar mukundansundar added this to the v1.13 milestone Sep 27, 2023
@mukundansundar mukundansundar removed their assignment Sep 29, 2023
@shivamkm07
Copy link
Contributor

/assign

@shivamkm07
Copy link
Contributor

This issue should be resolved with microsoft/durabletask-dotnet#194. It's also verified in dapr/dotnet-sdk#1155 that multiple events of the same name being created in parallel is working as expected. Can this issue be closed then @olitomlinson ?

@olitomlinson
Copy link
Author

Can confirm this issue is now fixed. Thanks @shivamkm07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants