-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,10 +138,15 @@ await this.LifeCycleNotificationHelper.OrchestratorStartingAsync( | |
byte[] triggerReturnValueBytes = Convert.FromBase64String(triggerReturnValue); | ||
P.OrchestratorResponse response = P.OrchestratorResponse.Parser.ParseFrom(triggerReturnValueBytes); | ||
context.SetResult( | ||
// TrySetResult may throw if a platform-level error is encountered (like an out of memory exception). | ||
context.TrySetResult( | ||
response.Actions.Select(ProtobufUtils.ToOrchestratorAction), | ||
response.CustomStatus); | ||
// Here we throw if the orchestrator completed with an application-level error. When we do this, | ||
// the function's result type will be of type `OrchestrationFailureException` which is reserved | ||
// for application-level errors that do not need to be re-tried. | ||
context.ThrowIfFailed(); | ||
}, | ||
#pragma warning restore CS0618 // Type or member is obsolete (not intended for general public use) | ||
|
@@ -159,6 +164,20 @@ await this.LifeCycleNotificationHelper.OrchestratorStartingAsync( | |
// Re-throw so we can abort this invocation. | ||
this.HostLifetimeService.OnStopping.ThrowIfCancellationRequested(); | ||
} | ||
|
||
// we abort the invocation on "platform level errors" such as: | ||
// - a timeout | ||
// - an out of memory exception | ||
// - a worker process exit | ||
if (functionResult.Exception is Host.FunctionTimeoutException | ||
// see in RemoteOrchestrationContext.TrySetResultInternal for details on OOM-handling | ||
Check warning on line 173 in src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs GitHub Actions / build
Check warning on line 173 in src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs GitHub Actions / build
Check warning on line 173 in src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs GitHub Actions / build
Check warning on line 173 in src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs GitHub Actions / build
Check warning on line 173 in src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs GitHub Actions / Analyze (csharp)
Check warning on line 173 in src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs GitHub Actions / Analyze (csharp)
Check warning on line 173 in src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs GitHub Actions / build
Check warning on line 173 in src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs GitHub Actions / build
|
||
|| functionResult.Exception?.InnerException is OutOfMemoryException | ||
|| (functionResult.Exception?.InnerException?.GetType().ToString().Contains("WorkerProcessExitException") ?? false)) | ||
{ | ||
// TODO: the `WorkerProcessExitException` type is not exposed in our dependencies, it's part of WebJobs.Host.Script. | ||
// Should we add that dependency or should it be exposed in WebJobs.Host? | ||
throw functionResult.Exception; | ||
} | ||
} | ||
catch (Exception hostRuntimeException) | ||
{ | ||
|
@@ -214,8 +233,7 @@ await this.LifeCycleNotificationHelper.OrchestratorCompletedAsync( | |
isReplay: false); | ||
} | ||
} | ||
else if (context.TryGetOrchestrationErrorDetails(out Exception? exception) | ||
&& (exception?.GetType() != typeof(OrchestrationFailureException) || !exception.Message.Contains("OutOfMemoryException"))) | ||
else if (context.TryGetOrchestrationErrorDetails(out Exception? exception)) | ||
{ | ||
// the function failed because the orchestrator failed. | ||
|
||
|
@@ -236,20 +254,6 @@ await this.LifeCycleNotificationHelper.OrchestratorFailedAsync( | |
exception?.Message ?? string.Empty, | ||
isReplay: false); | ||
} | ||
else if (exception?.GetType() == typeof(OrchestrationFailureException) && exception.Message.Contains("OutOfMemoryException")) | ||
{ | ||
string reason = $"Out Of Memory exception thrown by the worker runtime: {exception}"; | ||
|
||
this.TraceHelper.FunctionAborted( | ||
this.Options.HubName, | ||
functionName.Name, | ||
instance.InstanceId, | ||
reason, | ||
functionType: FunctionType.Orchestrator); | ||
|
||
// This will abort the current execution and force an durable retry | ||
throw new SessionAbortedException(reason); | ||
} | ||
else | ||
{ | ||
// the function failed for some other reason | ||
|
@@ -571,20 +575,6 @@ public async Task CallActivityAsync(DispatchMiddlewareContext dispatchContext, F | |
result: serializedOutput), | ||
}; | ||
} | ||
else if (result.Exception is not null && result.Exception.Message.Contains("OutOfMemoryException")) | ||
{ | ||
string reason = $"Out Of Memory exception thrown by the worker runtime: {result.Exception}"; | ||
|
||
this.TraceHelper.FunctionAborted( | ||
this.Options.HubName, | ||
functionName.Name, | ||
instance.InstanceId, | ||
reason, | ||
functionType: FunctionType.Activity); | ||
|
||
// This will abort the current execution and force an durable retry | ||
throw new SessionAbortedException(reason); | ||
} | ||
else | ||
{ | ||
this.TraceHelper.FunctionFailed( | ||
|