Repository navigation
Properly await throughput recording in MonitoringService - #5784
Merged
Merged
Conversation
Using List.ForEach with an async lambda resulted in async void calls that were not awaited, meaning the service could return before all endpoint data was persisted. Replacing this with a standard foreach loop ensures every operation is correctly awaited.
rbev
approved these changes
Aug 17, 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.
Problem
MonitoringService.RecordMonitoringThroughputiterated the endpoints in an incomingthroughput message with
List<T>.ForEach:ForEachtakes anAction<T>, so the lambda wasasync void. That has three consequences:RecordMonitoringThroughputreturned as soon as the firstawaitsuspended, so thetransport handler acknowledged the message while the writes were still outstanding. If
the process stopped in between, the data was gone and the message was not redelivered.
This is the path where a Monitoring instance reports throughput to the primary instance, and
that data feeds the usage report customers send to Particular. Losing it means under reported
usage.
How it was found
This came out of the EF acceptance tests work. It was not caught by the existing unit
tests because each of them sends a message containing a single endpoint, so there is nothing
to lose.