-
Notifications
You must be signed in to change notification settings - Fork 26
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
WeightedConnectionPool.getConnection returns null that leads to NoLivingConnectionsError error #53
Comments
detected while working on nodejs/undici#1065 and taking inspiration from the logic in this repo |
I'd like to open a PR with a fix after someone verifies my findings |
@rudolf can I work on a fix? |
Hi @jodevsa. We would be delighted to receive a pull request for this issue. Please read the contributing guidelines, and let us know when your fix is ready to review. Thanks :) |
The algorithm seems to be inspired by https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.863.3985&rep=rep1&type=pdf |
I just saw this :( HI @technige , Thanks for your kind message. I'll start working on a fix! |
🐛 Bug Report
requests sent after 6 requests that failed due to a timeout with a weightedConnectionPool that has 2 upstreams will fail with
NoLivingConnectionsError
even if the upstreams is running again and not timing out anymore.This is mostly due to the wrong assumption mentioned here:
https://github.com/elastic/elastic-transport-js/blob/main/src/pool/WeightedConnectionPool.ts#L54
if the GCD is 1 and both weights reached 1 after the subtraction we would need about 800 loops for current weight to reach 1 to be able to choose one of the weights
To Reproduce
Steps to reproduce the behavior:
1- clone my branch #54 which has a new test that should reproduce the bug
2- npm run build && node_modules/tap/bin/run.js test/unit/transport.test.ts
Paste your code here:
Expected behavior
we are able to use the pool after the upstreams are up again
Your Environment
The text was updated successfully, but these errors were encountered: