From 753d71d28debff5813c2e7fa8cbdebda8516173f Mon Sep 17 00:00:00 2001 From: sebastianburckhardt Date: Mon, 15 Apr 2024 08:42:15 -0700 Subject: [PATCH 1/2] fix race condition on mutable list of new events inside OrchestrationRuntimeState. --- .../OrchestrationService/NetheriteOrchestrationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DurableTask.Netherite/OrchestrationService/NetheriteOrchestrationService.cs b/src/DurableTask.Netherite/OrchestrationService/NetheriteOrchestrationService.cs index a28b63f6..a01eeb4b 100644 --- a/src/DurableTask.Netherite/OrchestrationService/NetheriteOrchestrationService.cs +++ b/src/DurableTask.Netherite/OrchestrationService/NetheriteOrchestrationService.cs @@ -876,7 +876,7 @@ Task IOrchestrationService.CompleteTaskOrchestrationWorkItemAsync( InstanceId = workItem.InstanceId, BatchStartPosition = messageBatch.BatchStartPosition, BatchLength = messageBatch.BatchLength, - NewEvents = (List)newOrchestrationRuntimeState.NewEvents, + NewEvents = newOrchestrationRuntimeState.NewEvents.ToList(), WorkItemForReuse = cacheWorkItemForReuse ? orchestrationWorkItem : null, PackPartitionTaskMessages = partition.Settings.PackPartitionTaskMessages, PersistFirst = partition.Settings.PersistStepsFirst ? BatchProcessed.PersistFirstStatus.Required : BatchProcessed.PersistFirstStatus.NotRequired, From 9b27132a850646c74e9ce060441a61f917c5cf63 Mon Sep 17 00:00:00 2001 From: Sebastian Burckhardt Date: Mon, 15 Apr 2024 11:23:35 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: David Justo --- .../OrchestrationService/NetheriteOrchestrationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DurableTask.Netherite/OrchestrationService/NetheriteOrchestrationService.cs b/src/DurableTask.Netherite/OrchestrationService/NetheriteOrchestrationService.cs index a01eeb4b..5b60c876 100644 --- a/src/DurableTask.Netherite/OrchestrationService/NetheriteOrchestrationService.cs +++ b/src/DurableTask.Netherite/OrchestrationService/NetheriteOrchestrationService.cs @@ -876,7 +876,7 @@ Task IOrchestrationService.CompleteTaskOrchestrationWorkItemAsync( InstanceId = workItem.InstanceId, BatchStartPosition = messageBatch.BatchStartPosition, BatchLength = messageBatch.BatchLength, - NewEvents = newOrchestrationRuntimeState.NewEvents.ToList(), + NewEvents = newOrchestrationRuntimeState.NewEvents.ToList(), // `NewEvents` in `newOrchestrationRuntimeState` may be mutated, so we copy to avoid a surprise change. WorkItemForReuse = cacheWorkItemForReuse ? orchestrationWorkItem : null, PackPartitionTaskMessages = partition.Settings.PackPartitionTaskMessages, PersistFirst = partition.Settings.PersistStepsFirst ? BatchProcessed.PersistFirstStatus.Required : BatchProcessed.PersistFirstStatus.NotRequired,