From aa00e37993bf4ac5b260dca8c2abb8366bc4ef09 Mon Sep 17 00:00:00 2001 From: raymonddenhaan <155616759+raymonddenhaan@users.noreply.github.com> Date: Mon, 4 Mar 2024 20:02:08 +0100 Subject: [PATCH] Added logging to pinpoint issue #5033 (#5034) --- .../DefaultWorkflowDefinitionStorePopulator.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowDefinitionStorePopulator.cs b/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowDefinitionStorePopulator.cs index 8431af360..cd9d0e3f1 100644 --- a/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowDefinitionStorePopulator.cs +++ b/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowDefinitionStorePopulator.cs @@ -178,6 +178,18 @@ public class DefaultWorkflowDefinitionStorePopulator : IWorkflowDefinitionStoreP workflowDefinition.MaterializerName = materializedWorkflow.MaterializerName; workflowDefinitionsToSave.Add(workflowDefinition); + + // Temporary measure to try and find the root cause of https://github.com/elsa-workflows/elsa-core/issues/5033 + var duplicates = workflowDefinitionsToSave.GroupBy(wd => wd.Id) + .Where(g => g.Count() > 1) + .Select(g => g.Key) + .ToList(); + + if (duplicates.Any()) + { + throw new Exception($"Unable to update WorkflowDefinition with ids {string.Join(',', duplicates)} multiple times."); + } + await _workflowDefinitionStore.SaveManyAsync(workflowDefinitionsToSave, cancellationToken); }