feat: also call picker.after_balance before retry (#2350)

This commit is contained in:
罗泽轩 2020-10-05 23:19:40 +08:00 committed by GitHub
parent 50c99a5e3b
commit 16a2d4dfa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -172,6 +172,10 @@ local function pick_server(route, ctx)
return nil, "no valid upstream node"
end
if ctx.server_picker and ctx.server_picker.after_balance then
ctx.server_picker.after_balance(ctx, true)
end
if up_conf.timeout then
local timeout = up_conf.timeout
local ok, err = set_timeouts(timeout.connect, timeout.send,

View File

@ -146,7 +146,12 @@ local function _ewma_find(ctx, up_nodes)
end
local function _ewma_after_balance(ctx)
local function _ewma_after_balance(ctx, before_retry)
if before_retry then
-- don't count tries which fail to complete
return nil
end
local response_time = tonumber(ctx.var.upstream_response_time) or 0
local connect_time = tonumber(ctx.var.upstream_connect_time) or 0
local rtt = connect_time + response_time

View File

@ -672,7 +672,7 @@ function _M.http_log_phase()
healcheck_passive(api_ctx)
if api_ctx.server_picker and api_ctx.server_picker.after_balance then
api_ctx.server_picker.after_balance(api_ctx)
api_ctx.server_picker.after_balance(api_ctx, false)
end
if api_ctx.uri_parse_param then