From: Ruediger Pluem Date: Wed, 15 Aug 2012 10:35:21 +0000 (+0000) Subject: Backport r1306409 from trunk: X-Git-Tag: 2.2.23~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbdc22683c97583e41036342afdfb61bbb5a936b;p=thirdparty%2Fapache%2Fhttpd.git Backport r1306409 from trunk: * 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 Submitted by: rpluem Reviewed by: rpluem, sf, rjung git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1373320 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index c6928d8492a..03a5084cc8a 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,9 @@ Changes with Apache 2.2.23 *) core: Fix building against PCRE 8.30 by switching from the obsolete pcre_info() to pcre_fullinfo(). PR 52623 [Ruediger Pluem, Rainer Jung] + *) mod_proxy: Add the forcerecovery balancer parameter that determines if + recovery for balancer workers is enforced. [Ruediger Pluem] + Changes with Apache 2.2.22 *) SECURITY: CVE-2011-3368 (cve.mitre.org) diff --git a/STATUS b/STATUS index 3c4af40dcb1..69304fbb3cc 100644 --- a/STATUS +++ b/STATUS @@ -93,16 +93,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_proxy: Add the forcerecovery balancer parameter that determines if - recovery for balancer workers is enforced. - Trunk version of patch: - http://svn.apache.org/viewvc?rev=1306409&view=rev - Backport version for 2.2.x of patch: - http://people.apache.org/~rpluem/patches/forcerecovery_2.2.diff - +1: rpluem, sf, rjung - sf notes: The docs should get a compatibility note once it is clear - in which 2.2.x version it gets introduced. - * mod_dumpio: Return an error code from a previous input filter PR 52914 Trunk patch: http://svn.apache.org/viewvc?rev=1301111&view=rev diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index 0577b693783..6969dfcd021 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -1005,6 +1005,16 @@ expressions in the list. Worker recovery behaves the same as other worker errors. Available with Apache HTTP Server 2.2.17 and later. + 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. + Available with Apache HTTP Server 2.2.23 and later. +

A sample balancer setup

diff --git a/include/ap_mmn.h b/include/ap_mmn.h index bee9853a4a5..f8ebeb7fae4 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -148,6 +148,7 @@ * altered in 2.2.18. Add ap_unescape_url_keep2f_ex(). * 20051115.29 (2.2.21) add max_ranges to core_dir_config * 20051115.30 (2.2.21) add ap_set_accept_ranges() + * 20051115.31 (2.2.23) Add forcerecovery to proxy_balancer_shared struct */ #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */ @@ -155,7 +156,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20051115 #endif -#define MODULE_MAGIC_NUMBER_MINOR 30 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 31 /* 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 fb9ff39dd32..8f8b61914e5 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, } } + else if (!strcasecmp(key, "forcerecovery")) { + if (!strcasecmp(val, "on")) + balancer->forcerecovery = 1; + else if (!strcasecmp(val, "off")) + balancer->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 97bb8c68a9f..759ae4a66ef 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -388,6 +388,7 @@ struct proxy_balancer { int scolonsep; /* true if ';' seps sticky session paths */ apr_array_header_t *errstatuses; /* statuses to force members into error */ + int forcerecovery; /* Force recovery if all workers are in error state */ }; struct proxy_balancer_method { diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 90f3d086edd..f757670a5b7 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -417,7 +417,7 @@ static void force_recovery(proxy_balancer *balancer, server_rec *s) } } } - if (!ok) { + if (!ok && balancer->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 a86c63d42fd..c64b0db5b1a 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1313,6 +1313,8 @@ PROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer, (*balancer)->name = uri; (*balancer)->lbmethod = lbmethod; (*balancer)->workers = apr_array_make(p, 5, sizeof(proxy_worker)); + + (*balancer)->forcerecovery = 1; /* XXX Is this a right place to create mutex */ #if APR_HAS_THREADS if (apr_thread_mutex_create(&((*balancer)->mutex),