From aa14a292f74528e72af658b03cb02d70f4a17094 Mon Sep 17 00:00:00 2001 From: Pradeep Kadubandi Date: Tue, 29 Aug 2017 23:42:43 -0700 Subject: [PATCH 1/2] Fix for the issue where issuing TerminateInstanceAsync twice from client before the orchestration is picked up by dispatcher leads to a blocked orchestration (the processing keeps abandoning the orchestration). (#113) Only the first terminate request is honored and subsequent terminates are ignored. (That makes the fix simple and hopefully not a problematic behavior from user's perspective) --- Framework/TaskOrchestrationContext.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Framework/TaskOrchestrationContext.cs b/Framework/TaskOrchestrationContext.cs index 91a48dac1..c0ea9bc6e 100644 --- a/Framework/TaskOrchestrationContext.cs +++ b/Framework/TaskOrchestrationContext.cs @@ -30,6 +30,7 @@ internal class TaskOrchestrationContext : OrchestrationContext readonly IDictionary orchestratorActionsMap; readonly TaskScheduler taskScheduler; OrchestrationCompleteOrchestratorAction continueAsNew; + bool executionTerminated; int idCounter; public TaskOrchestrationContext(OrchestrationInstance orchestrationInstance, TaskScheduler taskScheduler) @@ -340,7 +341,11 @@ public void HandleTimerFiredEvent(TimerFiredEvent timerFiredEvent) public void HandleExecutionTerminatedEvent(ExecutionTerminatedEvent terminatedEvent) { - CompleteOrchestration(terminatedEvent.Input, null, OrchestrationStatus.Terminated); + if (!executionTerminated) + { + executionTerminated = true; + CompleteOrchestration(terminatedEvent.Input, null, OrchestrationStatus.Terminated); + } } public void CompleteOrchestration(string result) From c81daed75ca455e180e12f5ab84a72b396d061c9 Mon Sep 17 00:00:00 2001 From: Chris Gillum Date: Fri, 2 Mar 2018 16:53:54 -0800 Subject: [PATCH 2/2] Handle the case where an orchestration completes and terminates at the same time (#143) --- Framework/TaskOrchestrationContext.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Framework/TaskOrchestrationContext.cs b/Framework/TaskOrchestrationContext.cs index c0ea9bc6e..6f4c852db 100644 --- a/Framework/TaskOrchestrationContext.cs +++ b/Framework/TaskOrchestrationContext.cs @@ -350,7 +350,10 @@ public void HandleExecutionTerminatedEvent(ExecutionTerminatedEvent terminatedEv public void CompleteOrchestration(string result) { - CompleteOrchestration(result, null, OrchestrationStatus.Completed); + if (!executionTerminated) + { + CompleteOrchestration(result, null, OrchestrationStatus.Completed); + } } public void FailOrchestration(Exception failure)