-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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(balancer): respect max retries #12242
Conversation
build/openresty/patches/ngx_lua-0.10.25_01-dyn_upstream_keepalive.patch
Outdated
Show resolved
Hide resolved
build/openresty/patches/ngx_lua-0.10.25_01-dyn_upstream_keepalive.patch
Outdated
Show resolved
Hide resolved
review companion: https://github.com/Kong/openresty-patches-review/pull/1/files |
new review companion: https://github.com/Kong/openresty-patches-review/pull/9/files |
build/openresty/patches/ngx_lua-0.10.25_01-dyn_upstream_keepalive.patch
Outdated
Show resolved
Hide resolved
Openresty patches review companion may not related to this pr and cc @fffonion |
a rebase will now solve the failing openresty patches companion CI @tzssangglass |
In the balancer phase, when obtaining a connection from the upstream connection pool, the `cached` attribute of the peer connection is set to 1(`pc->cached = 1;`), indicating that the connection is obtained from the cache. If an error occurs during the use of this connection, such as "upstream prematurely closed connection" the system will increase the `tries` attribute of the peer connection by executing `u->peer.tries++`. `tries` represents the maximum number of attempts to connect to an upstream server. It is equal to the normal 1 attempt + `retries` (default value is 5) = 6. The occurrence of `u->peer.tries++` is unexpected and it results in the actual retry count exceeding 6 in worst cases. This PR restores tries by callbacks to the balancer when `u->peer.tries++` is unexpectedly set. FIX [FTI-5616](https://konghq.atlassian.net/browse/FTI-5616) Signed-off-by: tzssangglass <tzssangglass@gmail.com>
Signed-off-by: tzssangglass <tzssangglass@gmail.com>
Signed-off-by: tzssangglass <tzssangglass@gmail.com>
Signed-off-by: tzssangglass <tzssangglass@gmail.com>
Signed-off-by: tzssangglass <tzssangglass@gmail.com>
Signed-off-by: tzssangglass <tzssangglass@gmail.com>
Signed-off-by: tzssangglass <tzssangglass@gmail.com>
e3701bd
to
7d69919
Compare
Due to some issues, I am unable to continue working on this PR until it is merged, so I have created a new PR #12346. |
Summary
In the balancer phase, when obtaining a connection from the upstream connection pool, the
cached
attribute of the peer connection is set to 1(pc->cached = 1;
), indicating that the connection is obtained from the cache.If an error occurs during the use of this connection, such as "upstream prematurely closed connection" the system will increase the
tries
attribute of the peer connection by executingu->peer.tries++
.tries
represents the maximum number of attempts to connect to an upstream server. It is equal to the normal 1 attempt +retries
(default value is 5) = 6.The occurrence of
u->peer.tries++
is unexpected and it results in the actual retry count exceeding 6 in worst cases.This PR restores tries by callbacks to the balancer when
u->peer.tries++
is unexpectedly set.Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
Fix FTI-5616