Skip to content

Commit

Permalink
fix race condition on OrchestrationRuntimeState.NewEvents (#380)
Browse files Browse the repository at this point in the history
* fix race condition on mutable list of new events inside OrchestrationRuntimeState.

* Apply suggestions from code review

Co-authored-by: David Justo <[email protected]>

---------

Co-authored-by: David Justo <[email protected]>
  • Loading branch information
sebastianburckhardt and davidmrdavid authored Apr 15, 2024
1 parent b885bd4 commit 2f94e76
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ Task IOrchestrationService.CompleteTaskOrchestrationWorkItemAsync(
InstanceId = workItem.InstanceId,
BatchStartPosition = messageBatch.BatchStartPosition,
BatchLength = messageBatch.BatchLength,
NewEvents = (List<HistoryEvent>)newOrchestrationRuntimeState.NewEvents,
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,
Expand Down

0 comments on commit 2f94e76

Please sign in to comment.