-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix: make set_more_retries() work when upstream_type is chash #2676
Conversation
apisix/balancer/chash.lua
Outdated
@@ -55,6 +55,7 @@ end | |||
|
|||
function _M.new(up_nodes, upstream) | |||
local str_null = str_char(0) | |||
local last_server_index |
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.
The last_server_index
should be in ctx scope, not the upstream one. We should not share the same index across different requests to an upstream.
apisix/balancer/chash.lua
Outdated
local id = picker:find(chash_key) | ||
local id | ||
if ctx.balancer_try_count > 1 and ctx.last_server_index then | ||
id, ctx.last_server_index = picker:next(ctx.last_server_index) |
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.
Better to use name like ctx.chash_last_server_index
Please write new test to verify the fix and make sure the tests are passed. |
ping @zfs123 |
This reverts commit 6cae977.
chash will pick next if last doesn't work to enable set_more_retries().
Pre-submission checklist: