From e7010edb27e341b974b7811f91856f5ca9e639cc Mon Sep 17 00:00:00 2001 From: Pradeep Kadubandi Date: Tue, 29 Aug 2017 14:40:37 -0700 Subject: [PATCH] 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). 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) --- src/DurableTask.Core/TaskOrchestrationContext.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/DurableTask.Core/TaskOrchestrationContext.cs b/src/DurableTask.Core/TaskOrchestrationContext.cs index 02afb9d12..b290b0072 100644 --- a/src/DurableTask.Core/TaskOrchestrationContext.cs +++ b/src/DurableTask.Core/TaskOrchestrationContext.cs @@ -33,6 +33,7 @@ internal class TaskOrchestrationContext : OrchestrationContext readonly IDictionary orchestratorActionsMap; readonly TaskScheduler taskScheduler; OrchestrationCompleteOrchestratorAction continueAsNew; + bool executionTerminated; int idCounter; public TaskOrchestrationContext(OrchestrationInstance orchestrationInstance, TaskScheduler taskScheduler) @@ -376,7 +377,11 @@ private void LogDuplicateEvent(string source, HistoryEvent historyEvent, int tas 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)