BalancedPool deteriorates to a single point of failure after outages
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 879
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 68
Description
Bug Description
After the configured backends for a balanced pool have failed for a bit, they all end up at equal low-end weights. If a balanced pool is configured with 2 hosts and 1 connection each, at this point the current implementation will always pick the same backend for further requests instead of switching between the 2 options. This causes a disruption to expand unnecessarily until whichever Backend ended up on top of the heap becomes healthy again.
The mechanism seems to work fine when more 2 hosts are added, recovering soon after one host is available.
Reproducible By
Set up a balanced pool with 2 hosts. Spam some requests while the hosts are down. Observe requests being sent.
Expected Behavior
Hosts of equal weight have equal chances of selection, leading to successful recovery when 1 of 2 hosts are available, regardless of ordering.
Logs & Screenshots
Let me know if a particular log would help the investigation. I'm not familiar with this projects best practices.
Environment
Undici 7.2.3 in project where I first observed the bug / current main branch for reproduction on private pc
Node 22, MacOS 26.3, Fedora 43
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the BalancedPool implementation and its weight or heap selection path; reproduce the two-host, one-connection case while both hosts are down. Compare selection behavior once both hosts have equal low-end weights, and add coverage for equal-chance recovery. Done means requests are no longer pinned to one backend when two hosts have equal weights.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100