Skip to content

fix: evict stale upstream countMap entries in LeastActiveLoadBalance - #6900

Open
juicewcode wants to merge 1 commit into
apache:masterfrom
juicewcode:fix/6891-least-active-load-balance-countmap-eviction
Open

fix: evict stale upstream countMap entries in LeastActiveLoadBalance #6900
juicewcode wants to merge 1 commit into
apache:masterfrom
juicewcode:fix/6891-least-active-load-balance-countmap-eviction

Conversation

@juicewcode

Copy link
Copy Markdown

Fixes #6891

  • Fix the memory leak in LeastActiveLoadBalance.countMap. Previously entries were only added and never removed, so an upstream's entry lingered forever after it was taken out of the list, causing unbounded memory growth proportional to historical upstream churn and O(n) scan overhead on every selection. Now stale entries whose domains are absent from the current upstream list are evicted via countMap.keySet().retainAll(domainMap.keySet()) before selection.
  • Added testRemoveStaleCountMapEntries to LeastActiveLoadBalanceTest. It registers two upstreams, removes one, and asserts the removed upstream's countMap entry is cleaned up while the remaining one is kept.

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

…pache#6891)

The countMap in LeastActiveLoadBalance accumulates an entry for every upstream domain ever observed, but had no removal path: when an upstream was removed from the list, its entry lingered indefinitely, leaking memory proportionally to historical upstream churn and adding O(n) scan overhead to every doSelect call. Now stale entries whose domains are absent from the current upstream list are removed before the least active domain is selected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] SelectorDataRefresh/RuleDataRefresh NPE on null data list (HTTP long-polling)

1 participant