-
Notifications
You must be signed in to change notification settings - Fork 328
Add poison message handling to the dispatchers #1366
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
base: main
Are you sure you want to change the base?
Changes from all commits
de244ff
8f6bf9d
ea5a36f
3ab0859
4c7665d
3bd1dc9
2e3c7c2
eecc077
f0fc35d
ea7a67f
c976817
559bb4d
68dbde9
b9a875d
8a77b40
c7d5803
b091049
868b856
d13c7b3
85ae250
7cbb931
756d592
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,12 @@ public ExecutionRewoundEvent(int eventId, string? reason) | |
| this.Reason = reason; | ||
| } | ||
|
|
||
| // Private ctor for JSON deserialization (required by some storage providers and out-of-proc executors) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR but I bug I found when testing (JSON was not able to deserialize this event because it lacked a 0-arg constructor and the other constructors all had multiple parameters) |
||
| ExecutionRewoundEvent() | ||
| : base(-1) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the event type | ||
| /// </summary> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // ---------------------------------------------------------------------------------- | ||
| // Copyright Microsoft Corporation | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // ---------------------------------------------------------------------------------- | ||
| #nullable enable | ||
| namespace DurableTask.Core | ||
| { | ||
| using System.Threading.Tasks; | ||
| using DurableTask.Core.History; | ||
|
|
||
| /// <summary> | ||
| /// Provides extensibility points for detecting and handling "poison" messages and invalid work items | ||
| /// in the task dispatchers. | ||
| /// </summary> | ||
| public interface IPoisonMessageHandler | ||
| { | ||
| /// <summary> | ||
| /// Determines whether the given <see cref="HistoryEvent"/> is a poison message. | ||
| /// </summary> | ||
| /// <param name="historyEvent">The history event being dispatched.</param> | ||
| /// <param name="reason">Why the message is considered poisoned.</param> | ||
| /// <returns><c>true</c> if the message should be treated as poisoned; otherwise <c>false</c>.</returns> | ||
| public bool IsPoisonMessage(HistoryEvent historyEvent, out string? reason); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need the backend to decide whether something is a poison message? Shouldn't the dispatcher be making this decision?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't, and it definitely can. I thought it would be the responsibility of the "poison message handler" since it's sort of in the name but this was just a somewhat arbitrary choice on my end. I can return responsibility to the dispatchers
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing that's tricky about reviewing this interface is that we don't yet have any implementations of it. I'm thinking we should probably implement this for Azure Storage before committing to these new public APIs.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually one thing I remembered is that doing it this way meant I didn't have to pass a |
||
|
|
||
| /// <summary> | ||
| /// Invoked to handle a poison message in the case that a message cannot necessarily | ||
| /// be "failed" by the dispatchers, so the <see cref="IPoisonMessageHandler"/> must | ||
| /// decide what to do. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// If this method returns false, the dispatcher should fall back to the default behavior | ||
| /// followed when poison message handling is not enabled. | ||
| /// </remarks> | ||
| /// <param name="orchestrationInstance">The orchestration instance the event was sent to, or null | ||
| /// if this information is not available.</param> | ||
| /// <param name="historyEvent">The "poisoned" history event.</param> | ||
| /// <param name="reason">The reason the event is "poisoned".</param> | ||
| /// <returns>True if the poison message was successfully handled, otherwise false.</returns> | ||
|
sophiatev marked this conversation as resolved.
|
||
| public Task<bool> HandlePoisonMessageAsync(OrchestrationInstance? orchestrationInstance, HistoryEvent historyEvent, string reason); | ||
|
|
||
| /// <summary> | ||
| /// Invoked to handle a work item that is invalid and cannot be processed at all. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// If this method returns false, the dispatcher should fall back to the default behavior | ||
| /// followed in the case of an invalid work item. | ||
| /// </remarks> | ||
| /// <param name="workItem">The work item that could not be processed.</param> | ||
| /// <param name="reason">Why the work item is invalid.</param> | ||
| /// <returns>True if the poison message was successfully handled, otherwise false.</returns> | ||
| public Task<bool> HandleInvalidWorkItemAsync(TaskOrchestrationWorkItem workItem, string reason); | ||
|
|
||
| /// <summary> | ||
| /// Invoked to handle a work item that is invalid and cannot be processed at all. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// If this method returns false, the dispatcher should fall back to the default behavior | ||
| /// followed in the case of an invalid work item. | ||
| /// </remarks> | ||
| /// <param name="workItem">The work item that could not be processed.</param> | ||
| /// <param name="reason">Why the work item is invalid.</param> | ||
| /// <returns>True if the poison message was successfully handled, otherwise false.</returns> | ||
| public Task<bool> HandleInvalidWorkItemAsync(TaskActivityWorkItem workItem, string reason); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the use case for
PoisonReasonin entity request messages?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used when generating the failure response for a poisoned entity operation, i.e. here.
Since processing the history event that corresponds to the entity request is decoupled from sending the response, we need to store the poison reason in the request message so we can use it later to populate the failure details.