Temporary solution to handle lagged stats listeners#1451
Merged
josecelano merged 2 commits intoApr 14, 2025
Merged
Conversation
for events channel to avoid lagged listeners. This does not fix the problem. Stats listener migth loose events and keep imprecise metrics.
If the stats listener is lagged we continue processing new events even if metrics become imprecise after it. This is a temporary solution. See torrust#1449.
Member
Author
|
ACK 6fdbc47 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1451 +/- ##
===========================================
- Coverage 84.52% 84.51% -0.01%
===========================================
Files 254 254
Lines 19157 19160 +3
Branches 19157 19160 +3
===========================================
+ Hits 16192 16194 +2
- Misses 2694 2695 +1
Partials 271 271 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Relates to: #1449
When I switched the channels for statistics from tokio mpsc to tokio broadcast, I introduced a bug that was only revealed after deploying the demo tracker.
The problem is that MPSC provides backpressure, so all events are processed. However, the broadcast channel has a limit, and listeners are informed with a
Laggederror when the limit has been reached and events have been deleted.We need to decide if:
In the meantime, I have increased the channel capacity to be able to collect all events at the current demo peak load. That should avoid the problem of loosing events in practice.
I have also fixed the listener to handle the
Laggederror. In this case, we don't have to break the loop but continue processing events to update metrics. The only difference is metrics will not be precise after this error happens because some events were lost.