Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Asynchronous close event handling for single peer upstreams

J Carter
May 11, 2023 08:12PM
On Sun, 7 May 2023 21:55:19 +0100
J Carter <jordanc.carter@outlook.com> wrote:

> # HG changeset patch
> # User jordanc.carter@outlook.com
> # Date 1683491710 -3600
> # Sun May 07 21:35:10 2023 +0100
> # Node ID e1ec9971da677b763c7576c729576d6f906631ae
> # Parent b71e69247483631bd8fc79a47cc32b762625b1fb
> Asynchronous close event handling for single peer upstreams
>
> Prevents additional upstream tries when consecutive asynchronous close
> errors are encountered for single peer upstreams utilizing keepalive
> connections.
>
> This replaces the current behavior of unlimited retries.
>
> diff -r b71e69247483 -r e1ec9971da67 src/event/ngx_event_connect.h
> --- a/src/event/ngx_event_connect.h Mon May 01 19:16:05 2023
> +0400 +++ b/src/event/ngx_event_connect.h Sun May 07 21:35:10
> 2023 +0100 @@ -17,6 +17,7 @@
> #define NGX_PEER_KEEPALIVE 1
> #define NGX_PEER_NEXT 2
> #define NGX_PEER_FAILED 4
> +#define NGX_PEER_ASYNC_FAILED 8
>
>
> typedef struct ngx_peer_connection_s ngx_peer_connection_t;
> @@ -64,6 +65,7 @@
> unsigned transparent:1;
> unsigned so_keepalive:1;
> unsigned down:1;
> + unsigned async_failed:1;
>
> /* ngx_connection_log_error_e */
> unsigned log_error:2;
> diff -r b71e69247483 -r e1ec9971da67 src/http/ngx_http_upstream.c
> --- a/src/http/ngx_http_upstream.c Mon May 01 19:16:05 2023
> +0400 +++ b/src/http/ngx_http_upstream.c Sun May 07 21:35:10
> 2023 +0100 @@ -4317,6 +4317,9 @@
> {
> state = NGX_PEER_NEXT;
>
> + } else if (u->peer.cached && ft_type ==
> NGX_HTTP_UPSTREAM_FT_ERROR) {
> + state = NGX_PEER_FAILED | NGX_PEER_ASYNC_FAILED;
> +
> } else {
> state = NGX_PEER_FAILED;
> }
> @@ -4330,11 +4333,6 @@
> "upstream timed out");
> }
>
> - if (u->peer.cached && ft_type == NGX_HTTP_UPSTREAM_FT_ERROR) {
> - /* TODO: inform balancer instead */
> - u->peer.tries++;
> - }
> -
> switch (ft_type) {
>
> case NGX_HTTP_UPSTREAM_FT_TIMEOUT:
> diff -r b71e69247483 -r e1ec9971da67
> src/http/ngx_http_upstream_round_robin.c ---
> a/src/http/ngx_http_upstream_round_robin.c Mon May 01 19:16:05
> 2023 +0400 +++ b/src/http/ngx_http_upstream_round_robin.c Sun
> May 07 21:35:10 2023 +0100 @@ -623,6 +623,12 @@
> ngx_http_upstream_rr_peers_unlock(rrp->peers);
> pc->tries = 0;
> +
> + if (state & NGX_PEER_ASYNC_FAILED && !pc->async_failed) {
> + pc->async_failed = 1;
> + pc->tries = 1;
> + }
> +
> return;
> }

Hello,

any opinions or suggestions for this patch?
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Asynchronous close event handling for single peer upstreams

J Carter 347 May 07, 2023 04:56PM

Re: [PATCH] Asynchronous close event handling for single peer upstreams

J Carter 99 May 11, 2023 08:12PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 324
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready