Skip to content
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

Merged
merged 7 commits into from
Jan 7, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apisix/balancer/chash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ function _M.new(up_nodes, upstream)
return {
upstream = upstream,
get = function (ctx)
local chash_key = fetch_chash_hash_key(ctx, upstream)
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)
Copy link
Member

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

else
local chash_key = fetch_chash_hash_key(ctx, upstream)
id, ctx.last_server_index = picker:find(chash_key)
end
-- core.log.warn("chash id: ", id, " val: ", servers[id])
return servers[id]
end
Expand Down