Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 45413 invoked from network); 17 Jul 2007 10:55:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jul 2007 10:55:50 -0000 Received: (qmail 25824 invoked by uid 500); 17 Jul 2007 06:51:51 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 25512 invoked by uid 500); 17 Jul 2007 06:51:49 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 25500 invoked by uid 99); 17 Jul 2007 06:51:49 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jul 2007 23:51:49 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [213.191.128.81] (HELO mxout2.iskon.hr) (213.191.128.81) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 16 Jul 2007 23:51:46 -0700 Received: (qmail 4107 invoked from network); 17 Jul 2007 08:51:23 +0200 X-Remote-IP: 213.191.142.124 Received: from unknown (HELO mx.iskon.hr) (213.191.142.124) by mxout2.iskon.hr with SMTP; 17 Jul 2007 08:51:23 +0200 Received: (qmail 978 invoked from network); 17 Jul 2007 08:51:23 +0200 X-AVScan: ClamAV X-Remote-IP: 89.164.18.175 Received: from 18-175.dsl.iskon.hr (HELO ?192.168.0.168?) (89.164.18.175) by mx.iskon.hr with SMTP; 17 Jul 2007 08:51:22 +0200 Message-ID: <469C66EA.3000601@apache.org> Date: Tue, 17 Jul 2007 08:51:22 +0200 From: Mladen Turk User-Agent: Mozilla MIME-Version: 1.0 To: dev@httpd.apache.org Subject: Re: httpd returns 500 when a route does not belong to the balancer. References: <46961263.7090006@gmail.com> In-Reply-To: <46961263.7090006@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org jean-frederic clere wrote: > Hi, > > I would like to fix a problem in mod_proxy_balancer when the > configuration is something like: > +++ > > ProxyPass balancer://mycluster/myapp > stickysession=JESSSIONID|jsessionid nofailover=On > > > > ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid > nofailover=On > > > > BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2 > > > BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto > > +++ > When jumping from /myapp with a JSESSIONID=id.test2 to /titi httpd > returns 500 but it should have ignored the route test2 because it > doesn't belong to any of the members of the balancer corresponding to > the location. > > Find attached a patch to fix the problem. > Here is my version of the patch. In essence it return 503 only when there is session route and this session route is not part of any load balancer member. It will allow to have the different load balancers with nofailover=On. Nofailover will work only for the load balancer members. Index: mod_proxy_balancer.c =================================================================== --- mod_proxy_balancer.c (revision 556817) +++ mod_proxy_balancer.c (working copy) @@ -180,7 +180,7 @@ int i; int checking_standby; int checked_standby; - + proxy_worker *worker; checking_standby = checked_standby = 0; @@ -389,7 +389,7 @@ for (i = 0; i < balancer->workers->nelts; i++, worker++) { if (!(worker->s->status & PROXY_WORKER_IN_ERROR)) { ok = 1; - break; + break; } } if (!ok) { @@ -470,15 +470,32 @@ *worker = runtime; } else if (route && (*balancer)->sticky_force) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "proxy: BALANCER: (%s). All workers are in error state for route (%s)", - (*balancer)->name, route); - if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, - "proxy: BALANCER: (%s). Unlock failed for pre_request", - (*balancer)->name); + int i, member_of = 0; + proxy_worker *workers; + /* + * We have a route provided that doesn't match the + * balancer name. See if the provider route is the + * member of the same balancer in which case return 503 + */ + workers = (proxy_worker *)(*balancer)->workers->elts; + for (i = 0; i < (*balancer)->workers->nelts; i++) { + if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) { + member_of = 1; + break; + } + workers++; } - return HTTP_SERVICE_UNAVAILABLE; + if (member_of) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, + "proxy: BALANCER: (%s). All workers are in error state for route (%s)", + (*balancer)->name, route); + if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, + "proxy: BALANCER: (%s). Unlock failed for pre_request", + (*balancer)->name); + } + return HTTP_SERVICE_UNAVAILABLE; + } } if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) { @@ -910,7 +927,7 @@ int max_lbset = 0; int checking_standby; int checked_standby; - + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy: Entering byrequests for BALANCER (%s)", balancer->name);