From e948002f960d31bf85bdba3c37712a2ace5ba626 Mon Sep 17 00:00:00 2001 From: Ruediger Pluem Date: Wed, 28 Mar 2012 15:22:40 +0000 Subject: [PATCH] * Add the forcerecovery balancer parameter that determines if recovery for balancer workers without considering the retry value of workers is enforced. There might be cases where an already overloaded backend can get into deeper trouble if the recovery of all workers is enforced without considering the retry parameter of each worker git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1306409 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ docs/manual/mod/mod_proxy.xml | 9 +++++++++ include/ap_mmn.h | 3 ++- modules/proxy/mod_proxy.c | 8 ++++++++ modules/proxy/mod_proxy.h | 1 + modules/proxy/mod_proxy_balancer.c | 2 +- modules/proxy/proxy_util.c | 2 ++ 7 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 4314ffeb4f..67d80e0b67 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_proxy: Add the forcerecovery balancer parameter that determines if + recovery for balancer workers is enforced. [Ruediger Pluem] + *) mod_proxy: Correctly set up reverse proxy worker. PR 52935. [Petter Berntsen ] diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index de26f3645d..0be2c0bd1d 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -1104,6 +1104,15 @@ expressions Number of additional BalancerMembers to allow to be added to this balancer in addition to those defined at configuration. + forcerecovery + On + Force the immediate recovery of all workers without considering the + retry parameter of the workers if all workers of a balancer are + in error state. There might be cases where an already overloaded backend + can get into deeper trouble if the recovery of all workers is enforced + without considering the retry parameter of each worker. In this case + set to Off. +

A sample balancer setup

diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 00572da2be..da2fc7c61f 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -395,6 +395,7 @@ * 20120211.0 (2.5.0-dev) Change re_nsub in ap_regex_t from apr_size_t to int. * 20120211.1 (2.5.0-dev) Add ap_palloc_debug, ap_pcalloc_debug * 20120211.2 (2.5.0-dev) Add ap_runtime_dir_relative + * 20120211.3 (2.5.0-dev) Add forcerecovery to proxy_balancer_shared struct */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ @@ -402,7 +403,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20120211 #endif -#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 3 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 8d289552d3..f9a800907a 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -387,6 +387,14 @@ static const char *set_balancer_param(proxy_server_conf *conf, return "growth must be between 1 and 100"; balancer->growth = ival; } + else if (!strcasecmp(key, "forcerecovery")) { + if (!strcasecmp(val, "on")) + balancer->s->forcerecovery = 1; + else if (!strcasecmp(val, "off")) + balancer->s->forcerecovery = 0; + else + return "forcerecovery must be On|Off"; + } else { return "unknown Balancer parameter"; } diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 5348d02a1f..5ad91fb595 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -424,6 +424,7 @@ typedef struct { unsigned int need_reset:1; unsigned int vhosted:1; unsigned int inactive:1; + unsigned int forcerecovery:1; } proxy_balancer_shared; #define ALIGNED_PROXY_BALANCER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_balancer_shared))) diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 28eb176884..e3db4883f1 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -423,7 +423,7 @@ static void force_recovery(proxy_balancer *balancer, server_rec *s) } } } - if (!ok) { + if (!ok && balancer->s->forcerecovery) { /* If all workers are in error state force the recovery. */ worker = (proxy_worker **)balancer->workers->elts; diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 5821aa9300..fe2ac43e20 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1164,6 +1164,8 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p, bshared->hash.fnv = ap_proxy_hashfunc(bshared->name, PROXY_HASHFUNC_FNV); (*balancer)->hash = bshared->hash; + bshared->forcerecovery = 1; + /* Retrieve a UUID and store the nonce for the lifetime of * the process. */ apr_uuid_get(&uuid); -- 2.40.0