fix race condition on OrchestrationRuntimeState.NewEvents (#380)

* fix race condition on mutable list of new events inside OrchestrationRuntimeState.

* Apply suggestions from code review

Co-authored-by: David Justo <david.justo.1996@gmail.com>

---------

Co-authored-by: David Justo <david.justo.1996@gmail.com>
This commit is contained in:
Sebastian Burckhardt 2024-04-15 11:29:07 -07:00 коммит произвёл GitHub
Родитель b885bd4a8c
Коммит 2f94e765d5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -876,7 +876,7 @@ namespace DurableTask.Netherite
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,