danielgerlag / danielgerlag/workflow-core

QueueConsumer _secondPasses are not cleared when Workflow has ended or terminated.

Open
#1,417 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
5.9k
Forks
1.3k
Avg merge
1d 1h
Merged PRs (30d)
5

Description

**Describe the bug**
QueueConsumer _secondPasses are not cleared when Workflow has ended or terminated.

**To Reproduce**
We used WorkflowPurger to clean Workflows with Status 2 or 3 to clean SQL Server database. After that 2 errors appeared for the deleted records:

"_Error processing workflow "8fa9ba29-2232-4705-b8bd-2833a56147cc"__"
"_Error executing item 8fa9ba29-2232-4705-b8bd-2833a56147cc - Sequence contains no elements._"

That workflowId (InstanceId) was one of those which were deleted from the database. We used SingleNodeQueueProvider but I dont think this will change with different provider.

**Expected behavior**
After Workflow End (Status=2) or Termination (Status=3) the workflowId should be cleared from all queues.

**Additional context**
Maybe you only need to add cleaning _secondPasses to the finally block of the ExecuteItem method. Something like this:

` finally
{
waitHandle.Set();
_secondPasses.TryRemove(itemId); // Fix #1: cleanup i when exception/cancellation occurs
lock (_activeTasks)
{
_activeTasks.Remove(itemId);
}
lock (_runningTasksLock)
{
_runningTasks.RemoveAll(t => t.IsCompleted); // Fix #2: cleanup done tasks
}
}`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.