From cc86d58043440c3f497b06b82e20f50909da52c9 Mon Sep 17 00:00:00 2001 From: lijunlong Date: Tue, 9 Jul 2024 11:41:35 +0800 Subject: [PATCH] feature: more patch for balancer_pool_max_retry. --- ...nginx-1.19.9-balancer_pool_max_retry.patch | 27 +++++++++++++++++++ ...nginx-1.21.4-balancer_pool_max_retry.patch | 27 +++++++++++++++++++ ...nginx-1.25.3-balancer_pool_max_retry.patch | 27 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 patches/nginx-1.19.9-balancer_pool_max_retry.patch create mode 100644 patches/nginx-1.21.4-balancer_pool_max_retry.patch create mode 100644 patches/nginx-1.25.3-balancer_pool_max_retry.patch diff --git a/patches/nginx-1.19.9-balancer_pool_max_retry.patch b/patches/nginx-1.19.9-balancer_pool_max_retry.patch new file mode 100644 index 0000000..8ee44ea --- /dev/null +++ b/patches/nginx-1.19.9-balancer_pool_max_retry.patch @@ -0,0 +1,27 @@ +diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c +index d04d91e..397cb08 100644 +--- a/src/http/ngx_http_upstream.c ++++ b/src/http/ngx_http_upstream.c +@@ -4378,6 +4378,9 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u, + if (u->peer.cached && ft_type == NGX_HTTP_UPSTREAM_FT_ERROR) { + /* TODO: inform balancer instead */ + u->peer.tries++; ++ if (u->peer.notify) { ++ u->peer.notify(&u->peer, u->peer.data, NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR); ++ } + } + + switch (ft_type) { +diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h +index f6621af..2b5957e 100644 +--- a/src/http/ngx_http_upstream.h ++++ b/src/http/ngx_http_upstream.h +@@ -55,6 +55,8 @@ + #define NGX_HTTP_UPSTREAM_IGN_XA_CHARSET 0x00000100 + #define NGX_HTTP_UPSTREAM_IGN_VARY 0x00000200 + ++#define NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR 0x1 ++ + + typedef struct { + ngx_uint_t status; diff --git a/patches/nginx-1.21.4-balancer_pool_max_retry.patch b/patches/nginx-1.21.4-balancer_pool_max_retry.patch new file mode 100644 index 0000000..8ee44ea --- /dev/null +++ b/patches/nginx-1.21.4-balancer_pool_max_retry.patch @@ -0,0 +1,27 @@ +diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c +index d04d91e..397cb08 100644 +--- a/src/http/ngx_http_upstream.c ++++ b/src/http/ngx_http_upstream.c +@@ -4378,6 +4378,9 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u, + if (u->peer.cached && ft_type == NGX_HTTP_UPSTREAM_FT_ERROR) { + /* TODO: inform balancer instead */ + u->peer.tries++; ++ if (u->peer.notify) { ++ u->peer.notify(&u->peer, u->peer.data, NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR); ++ } + } + + switch (ft_type) { +diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h +index f6621af..2b5957e 100644 +--- a/src/http/ngx_http_upstream.h ++++ b/src/http/ngx_http_upstream.h +@@ -55,6 +55,8 @@ + #define NGX_HTTP_UPSTREAM_IGN_XA_CHARSET 0x00000100 + #define NGX_HTTP_UPSTREAM_IGN_VARY 0x00000200 + ++#define NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR 0x1 ++ + + typedef struct { + ngx_uint_t status; diff --git a/patches/nginx-1.25.3-balancer_pool_max_retry.patch b/patches/nginx-1.25.3-balancer_pool_max_retry.patch new file mode 100644 index 0000000..8ee44ea --- /dev/null +++ b/patches/nginx-1.25.3-balancer_pool_max_retry.patch @@ -0,0 +1,27 @@ +diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c +index d04d91e..397cb08 100644 +--- a/src/http/ngx_http_upstream.c ++++ b/src/http/ngx_http_upstream.c +@@ -4378,6 +4378,9 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u, + if (u->peer.cached && ft_type == NGX_HTTP_UPSTREAM_FT_ERROR) { + /* TODO: inform balancer instead */ + u->peer.tries++; ++ if (u->peer.notify) { ++ u->peer.notify(&u->peer, u->peer.data, NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR); ++ } + } + + switch (ft_type) { +diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h +index f6621af..2b5957e 100644 +--- a/src/http/ngx_http_upstream.h ++++ b/src/http/ngx_http_upstream.h +@@ -55,6 +55,8 @@ + #define NGX_HTTP_UPSTREAM_IGN_XA_CHARSET 0x00000100 + #define NGX_HTTP_UPSTREAM_IGN_VARY 0x00000200 + ++#define NGX_HTTP_UPSTREAM_NOTIFY_CACHED_CONNECTION_ERROR 0x1 ++ + + typedef struct { + ngx_uint_t status;