Repository navigation
Fix unbounded completed task retention in queue consumers - #1454
Merged
danielgerlag merged 1 commit intoOct 25, 2026
Merged
danielgerlag merged 1 commit into
danielgerlag merged 1 commit into
Conversation
danielgerlag
approved these changes
Oct 25, 2026
danielgerlag
left a comment
Owner
There was a problem hiding this comment.
Looks good — this correctly bounds _runningTasks to in-flight (+ at most one just-completed) work under the existing lock, without changing dispatch, shutdown wait, or public API.
The regression test is solid: holds two items in flight, processes 100 completed ones, and asserts completed tasks are pruned while both unfinished tasks remain.
One optional nit (non-blocking): when the dispatcher is idle after the last batch, completed tasks aren't pruned until the next dequeue. That's fine for the #1448 leak (growth with throughput); only matters if someone inspects the list after idle. Could also prune once in the shutdown path before WhenAll, but not required.
Approving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the change
Fixes #1448: prevent the queue consumers' completed-task list from growing with the total number of items processed by the host.
A dummy in-memory workflow run through
AddWorkflow/IWorkflowHost.StartWorkflowretained 222 workflow-consumer tasks after 200 sequential one-step workflows (plus preceding input/output, event and retry workflows). With this change the same run retained one task. This measures retained task references, not process RSS or OS handle usage.Describe your implementation or design
Prune completed tasks under the existing
_runningTasksLockbefore tracking each newly dispatched task. In-flight tasks remain tracked for the existing shutdown wait. When dispatch is idle the final bounded batch can remain; retention no longer grows with lifetime throughput. No continuation per item, public API, cancellation semantics, wait-handle lifecycle or shutdown rewrite is introduced.Tests
git diff --checkpasses.Limits: .NET 6/8 test targets and external database/provider suites were not run locally; no cross-process durability, distributed behavior or performance certification is claimed.
Breaking change
None; only completed task references are removed from the private list.