-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Bug in LeastConnSelection Policy used in reverseproxy #5609
Comments
Oh I think that was meant to be an |
I think we can use the condition:
It will handle the condition: if the count is 1, random number won't be generated, otherwise will be generated. @francislavoie |
Does this still need to be fixed, @yashkundu ? |
@mholt , yes, It's a small fix, I can fix it and raise a pr? |
That would be splendid 🙏 thank you! |
FYI @yashkundu #5862 |
There is a BUG in the way LeastConnSelection policy is selecting an upstream for the reverse proxy.
The following is the code of the select method of LeastConnSelection struct which chooses the upstream:
caddy/blob/master/modules/caddyhttp/reverseproxy/selectionpolicies.go
This always selects the last upstream which has the least number of active requests, but it should randomly choose among all the upstreams which have the least number of active requests, reservoir sampling is implemented incorrecly, because of the extra condition (count>1) in the if clause.
The text was updated successfully, but these errors were encountered: