Skip to content

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

@stechklvana

Description

@stechklvana

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 } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions