-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix stale entries before the each pick operation #3690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a memory leak issue in the weighted round-robin (WRR) load balancer by implementing cleanup logic for stale entries in the currentWeight
map. When service discovery updates the node list, old entries were persisting in the map and could affect future weight calculations.
Key changes:
- Added cleanup logic to remove stale entries from the
currentWeight
map before each pick operation - Moved mutex locking to encompass the entire cleanup and selection process
- Added comprehensive test coverage to verify the cleanup functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
selector/wrr/wrr.go | Implements cleanup logic for stale entries and reorganizes mutex usage |
selector/wrr/wrr_test.go | Adds test coverage for the cleanup functionality with mock weighted nodes |
@tonybase PTAL |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
The original implementation had a critical flaw in the
currentWeight
map management:currentWeight
map accumulated entries for every node address that was ever encounteredDescription (what this PR does / why we need it):
Which issue(s) this PR fixes (resolves / be part of):
Other special notes for the reviewers: