Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition in BatchBlock's handling of completion (#38651)
When a BatchBlock is marked for completion, it will no longer consume postponed messages. But the BatchesNeedProcessing method, which factors in the number of postponed messages, is accidentally ignoring the _decliningPermanently flag that indicates completion was requested. As a result, with just the right sequence of operations, the BatchBlock can get stuck in a state where it sees postponed messages and queues a task to process them, but that task then sees that it's declining permanently and so doesn't touch any of the postponed messages, and then upon checking to see if it can complete, sees there are postponed messages, and loops again, resulting in a potentially infinite asynchronous loop. The fix is just to check _decliningPermanently in BatchesNeedProcessing when considering postponed messages.
- Loading branch information