danielgerlag / danielgerlag/workflow-core
PersistedWorkflow ExecutionPointers exponentially increase in workflow loop.
- Dominant language
- C#
- Stars
- 5.9k
- Forks
- 1.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 5
Description
**Describe the bug**
Workflows that loop over steps double the number of ExecutionPointers with each loop. This is causing exponential slowdown with each iteration. This seems to be stemming from the filter loop in the Execute method in the the WorkflowExecutor that filters out inactive pointers [Execute method](https://github.com/danielgerlag/workflow-core/blob/master/src/WorkflowCore/Services/WorkflowExecutor.cs#:~:text=var%20exePointers%20%3D%20new%20List%3CExecutionPointer%3E(workflow.ExecutionPointers.Where(x%20%3D%3E%20x.Active%20%26%26%20(!x.SleepUntil.HasValue%20%7C%7C%20x.SleepUntil%20%3C%20_datetimeProvider.UtcNow)))%3B).
**To Reproduce**
Create a workflow that loops over the same steps. With each successive iteration check the ExecutionPointers count and time it takes to complete the loop.
**Expected behavior**
Looping behavior should not be increasing the execution time of a workflow
**Additional context**
With only the active pointers being used, is it necessary to persist the inactive pointers? To alleviate the problem
[these changes ](https://github.com/ditinc/workflow-core/commit/04a1d5e33caa817754e1df246c708a30f9c100ec#:~:text=var%20raw%20%3D%20await,InstanceId%20%3D%3D%20uid%2C%20cancellationToken) were made to the EntityFrameworkPersistenceProvider in our forked repo. With these changes each iteration is being performed at a consistent time and no unintended effects have been observed (yet).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.