Repository navigation
Fix payload retries and entity cleanup after storage failures #816
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
Open
wangbill (YunchuWang)
wants to merge
6
commits into
main
Choose a base branch
from
yunchuwang-public-sdk-payload-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
86d2435
Fix payload retries and entity cleanup after storage failures
YunchuWang f9baad3
Keep payload preparation wiring free of new warnings
YunchuWang fdeeedb
Refine payload cleanup and cover permanent upload failures
YunchuWang f3949e2
Register payload preparation through a worker-owned API
YunchuWang 6f374ae
Preserve terminal cleanup in standalone response conversion
YunchuWang 60abcc4
Merge main into payload fixes
YunchuWang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,50 @@ public sealed class AzureBlobPayloadsSideCarInterceptor(PayloadStore payloadStor | |
|
|
||
| Action<object>? SharedMessageLockAcquiredForTest { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Externalizes a response before the worker finalizes terminal entity cleanup. | ||
| /// </summary> | ||
| /// <param name="response">The orchestration response.</param> | ||
| /// <param name="cancellation">Cancellation token.</param> | ||
| /// <returns>A task representing response preparation.</returns> | ||
| internal async Task PrepareOrchestratorResponseAsync(P.OrchestratorResponse response, CancellationToken cancellation) | ||
| { | ||
| try | ||
| { | ||
| await this.ExternalizeOrchestratorResponseAsync(response, cancellation); | ||
| } | ||
| catch (Exception ex) when (IsPermanentStorageFailure(ex)) | ||
| { | ||
| // Retain entity releases when replacing actions with a Failed completion so | ||
| // the orchestration terminates without leaving its entities locked. | ||
| P.OrchestratorAction[] unlocks = response.Actions.Where(action => | ||
| action.SendEntityMessage?.EntityUnlockSent is not null | ||
| || (action.SendEvent is { Name: "release", Instance: { } instance } | ||
|
Comment on lines
+46
to
+48
Member
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. why |
||
| && global::DurableTask.Core.Common.Entities.IsEntityInstance(instance.InstanceId))).ToArray(); | ||
| response.Actions.Clear(); | ||
| response.Actions.AddRange(unlocks); | ||
| response.CustomStatus = null; | ||
| #pragma warning disable CS0612 // isPartial/chunkIndex are deprecated but still required for chunked response wire compatibility. | ||
| response.IsPartial = false; | ||
| response.ChunkIndex = null; | ||
| #pragma warning restore CS0612 | ||
| response.Actions.Add(new P.OrchestratorAction | ||
| { | ||
| CompleteOrchestration = new P.CompleteOrchestrationAction | ||
| { | ||
| OrchestrationStatus = P.OrchestrationStatus.Failed, | ||
| FailureDetails = new P.TaskFailureDetails | ||
| { | ||
| ErrorType = ex.GetType().FullName, | ||
| ErrorMessage = ex.Message, | ||
| StackTrace = ex.StackTrace, | ||
| IsNonRetriable = true, | ||
| }, | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| protected override async Task ExternalizeRequestPayloadsAsync<TRequest>(TRequest request, CancellationToken cancellation) | ||
| { | ||
|
|
@@ -76,37 +120,7 @@ protected override async Task ExternalizeRequestPayloadsAsync<TRequest>(TRequest | |
|
|
||
| break; | ||
| case P.OrchestratorResponse r: | ||
| try | ||
| { | ||
| await this.ExternalizeOrchestratorResponseAsync(r, cancellation); | ||
| } | ||
| catch (Exception ex) when (IsPermanentStorageFailure(ex)) | ||
| { | ||
| // Permanent failure during orchestration response externalization. | ||
| // Replace all actions with a single Failed completion so the orchestration | ||
| // terminates instead of being abandoned and redelivered indefinitely. | ||
| r.Actions.Clear(); | ||
| r.CustomStatus = null; | ||
| #pragma warning disable CS0612 // isPartial/chunkIndex are deprecated but still required for chunked response wire compatibility. | ||
| r.IsPartial = false; | ||
| r.ChunkIndex = null; | ||
| #pragma warning restore CS0612 | ||
| r.Actions.Add(new P.OrchestratorAction | ||
| { | ||
| CompleteOrchestration = new P.CompleteOrchestrationAction | ||
| { | ||
| OrchestrationStatus = P.OrchestrationStatus.Failed, | ||
| FailureDetails = new P.TaskFailureDetails | ||
| { | ||
| ErrorType = ex.GetType().FullName, | ||
| ErrorMessage = ex.Message, | ||
| StackTrace = ex.StackTrace, | ||
| IsNonRetriable = true, | ||
| }, | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| await this.PrepareOrchestratorResponseAsync(r, cancellation); | ||
| break; | ||
| case P.EntityBatchResult r: | ||
| await this.ExternalizeEntityBatchResultAsync(r, cancellation); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why need this check, and isentityinstance check, seem unnccessary