Repository navigation
fix(operator): consume the timed entity queue without blocking a thread pool thread - #1313
Merged
Merged
Conversation
…ad pool thread TimedEntityQueue consumed its BlockingCollection via GetConsumingEnumerable inside an async iterator, so every consumer blocked a thread pool thread for its whole lifetime. Back the ready queue with an unbounded Channel<T> and read it asynchronously. Disposing the queue completes the channel, which ends running consumers. Closes #1308.
kimpenhaus
enabled auto-merge (squash)
November 7, 2026 11:06
|
🎉 This PR is included in version 13.3.6 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This was referenced Nov 13, 2026
This was referenced Nov 20, 2026
This was referenced Nov 30, 2026
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.
Closes #1308.
Problem
TimedEntityQueue<TEntity>.GetAsyncEnumeratorconsumed itsBlockingCollectionviaGetConsumingEnumerableinside an async iterator. Every consumer therefore blocked a thread pool thread for its whole lifetime — one per entity type — and the queue's timer loop and all other async work competed for the remaining threads.Changes
Channel<QueueEntry<TEntity>>;GetAsyncEnumeratorreads it withReadAllAsync. Multiple readers stay allowed, since a leadership flap can briefly overlap two consumer loops.Clear()drains viaTryReadand never completes the channel, so the queue stays usable afterResumeIntake().Dispose()completes the channel, which ends running consumers gracefully (previously they would have hit the disposed collection).queue-strategy.mdxnow recommends an asynchronous wait for customITimedEntityQueue<TEntity>implementations.Test
New regression test
Waiting_For_Entries_Should_Not_Block_The_Consumer_Thread(areaThreadPool): the consumer and a probe run on a scheduler that executes one task at a time, in order. A consumer that blocks its thread while the queue is empty keeps the probe from ever running; an asynchronous consumer releases the scheduler while it waits. The test is deterministic and does not depend on timing.The full test suite passes (843 tests, 8 skipped).