Skip to content

bugfix: respect max retry after using balancer pool #2331

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

Merged
merged 2 commits into from
Jul 9, 2024

Conversation

tzssangglass
Copy link
Contributor

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++.

This PR restores tries by callbacks to the balancer when u->peer.tries++ is unexpectedly set.

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.

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++`.

This PR restores tries by callbacks to the balancer when
`u->peer.tries++` is unexpectedly set.

Signed-off-by: tzssangglass <[email protected]>
@tzssangglass
Copy link
Contributor Author

@zhuizhuhaomeng
Copy link
Contributor

/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_balancer.c: In function ‘ngx_http_lua_balancer_notify_peer’:
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_balancer.c:747:17: error: ‘NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR’ undeclared (first use in this function); did you mean ‘NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL’?
  747 |     if (type == NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR) {
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                 NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_balancer.c:747:17: note: each undeclared identifier is reported only once for each function it appears in

@tzssangglass
Copy link
Contributor Author

/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_balancer.c: In function ‘ngx_http_lua_balancer_notify_peer’:
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_balancer.c:747:17: error: ‘NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR’ undeclared (first use in this function); did you mean ‘NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL’?
747 | if (type == NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL
/home/travis/build/openresty/lua-nginx-module/src/ngx_http_lua_balancer.c:747:17: note: each undeclared identifier is reported only once for each function it appears in

https://github.com/openresty/openresty/pull/986/files

@zhuizhuhaomeng zhuizhuhaomeng merged commit 94f55f7 into openresty:master Jul 9, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants