Re: httpd returns 500 when a route does not belong to the balancer.
Mladen... stupid question, but what is this stuff in the code @@ -470,15 +470,32 @@ ? - Original Message - From: Mladen Turk [EMAIL PROTECTED] To: dev@httpd.apache.org Sent: Tuesday, July 17, 2007 8:51 AM Subject: Re: httpd returns 500 when a route does not belong to the balancer. jean-frederic clere wrote: Hi, I would like to fix a problem in mod_proxy_balancer when the configuration is something like: +++ Location /myapp ProxyPass balancer://mycluster/myapp stickysession=JESSSIONID|jsessionid nofailover=On /Location Location /titi ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid nofailover=On /Location Proxy balancer://mytiti BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2 /Proxy Proxy balancer://mycluster BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto /Proxy +++ 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);
Re: httpd returns 500 when a route does not belong to the balancer.
Johnny Kewl wrote: Mladen... stupid question, but what is this stuff in the code @@ -470,15 +470,32 @@ http://www.network-theory.co.uk/articles/patchintro.html It doesn't exactly explain the format of the patch file, but it can be helpful :) Regards, Mladen
Re: httpd returns 500 when a route does not belong to the balancer.
Mladen Turk wrote: jean-frederic clere wrote: Hi, I would like to fix a problem in mod_proxy_balancer when the configuration is something like: +++ Location /myapp ProxyPass balancer://mycluster/myapp stickysession=JESSSIONID|jsessionid nofailover=On /Location Location /titi ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid nofailover=On /Location Proxy balancer://mytiti BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2 /Proxy Proxy balancer://mycluster BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto /Proxy +++ 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. +1 for concept : It does the same mine was doing. But it avoids the changes in find_route_worker() it creates an extra loop but only when the route doesn't match which shouldn't occur in all requests. Please avoid the @@ -180,7 +180,7 @@ and @@ -389,7 +389,7 @@ and @@ -910,7 +927,7 @@ parts and the typos... Like in the attached patch. Cheers Jean-Frederic 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); Index: modules/proxy/mod_proxy_balancer.c === --- modules/proxy/mod_proxy_balancer.c (revision 556901) +++ modules/proxy/mod_proxy_balancer.c (working copy) @@ -470,15 +470,31 @@ *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); +
Re: httpd returns 500 when a route does not belong to the balancer.
-Ursprüngliche Nachricht- Von: jean-frederic clere Gesendet: Donnerstag, 12. Juli 2007 13:37 An: dev@httpd.apache.org Betreff: httpd returns 500 when a route does not belong to the balancer. Hi, I would like to fix a problem in mod_proxy_balancer when the configuration is something like: +++ Location /myapp ProxyPass balancer://mycluster/myapp stickysession=JESSSIONID|jsessionid nofailover=On /Location Location /titi ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid nofailover=On /Location Proxy balancer://mytiti BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2 /Proxy Proxy balancer://mycluster BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto /Proxy +++ 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. To be honest the correct fix IMHO is to set the correct path for the cookie such that the browser does not sent the wrong sessionid when switching from myapp to titi and vice versa. If you do not do this you always loose your session when you switch between both applications which is unlikely to be the desired behaviour. Nevertheless the patch looks ok, but given the above I am -0 on it. Regards Rüdiger
Re: httpd returns 500 when a route does not belong to the balancer.
jean-frederic clere wrote: Hi, I would like to fix a problem in mod_proxy_balancer when the configuration is something like: +++ Location /myapp ProxyPass balancer://mycluster/myapp stickysession=JESSSIONID|jsessionid nofailover=On /Location Location /titi ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid nofailover=On /Location Proxy balancer://mytiti BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2 /Proxy Proxy balancer://mycluster BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto /Proxy +++ 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. Comments? Hmm, nofailover=On is used for non-matched routes. It returns 500 instead forcing re-login (if there is no session replication or SSO, and that's why it was designed at the first place) If you have cross site then simply use nofailover=Off and then your app will either require re-login or continue working if there is SSO/session replication. -0.5 on the patch, cause IMO commenting nofailover should make things work. Regards, Mladen.
Re: httpd returns 500 when a route does not belong to the balancer.
Plüm wrote: -Ursprüngliche Nachricht- Von: jean-frederic clere Gesendet: Donnerstag, 12. Juli 2007 13:37 An: dev@httpd.apache.org Betreff: httpd returns 500 when a route does not belong to the balancer. Hi, I would like to fix a problem in mod_proxy_balancer when the configuration is something like: +++ Location /myapp ProxyPass balancer://mycluster/myapp stickysession=JESSSIONID|jsessionid nofailover=On /Location Location /titi ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid nofailover=On /Location Proxy balancer://mytiti BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2 /Proxy Proxy balancer://mycluster BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto /Proxy +++ 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. To be honest the correct fix IMHO is to set the correct path for the cookie such that the browser does not sent the wrong sessionid when switching from myapp to titi and vice versa. If you do not do this you always loose your session when you switch between both applications which is unlikely to be the desired behaviour. The problem in fact occurs when there is a single sign on configuration on both applications and each application is running in a different cluster. It is not possible to set the cookie path to /titi or /myapp in this case. Cheers Jean-Frederic Nevertheless the patch looks ok, but given the above I am -0 on it. Regards Rüdiger
Re: httpd returns 500 when a route does not belong to the balancer.
Mladen Turk wrote: jean-frederic clere wrote: Hi, I would like to fix a problem in mod_proxy_balancer when the configuration is something like: +++ Location /myapp ProxyPass balancer://mycluster/myapp stickysession=JESSSIONID|jsessionid nofailover=On /Location Location /titi ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid nofailover=On /Location Proxy balancer://mytiti BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2 /Proxy Proxy balancer://mycluster BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto /Proxy +++ 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. Comments? Hmm, nofailover=On is used for non-matched routes. The failover stuff is between the members of a balancer not between balancers. It returns 500 instead forcing re-login (if there is no session replication or SSO, and that's why it was designed at the first place) It returns 500 forever ;-( Cheers Jean-Frederic If you have cross site then simply use nofailover=Off and then your app will either require re-login or continue working if there is SSO/session replication. -0.5 on the patch, cause IMO commenting nofailover should make things work. Regards, Mladen.
Re: httpd returns 500 when a route does not belong to the balancer.
jean-frederic clere wrote: Mladen Turk wrote: jean-frederic clere wrote: Hi, I would like to fix a problem in mod_proxy_balancer when the configuration is something like: +++ Location /myapp ProxyPass balancer://mycluster/myapp stickysession=JESSSIONID|jsessionid nofailover=On /Location Location /titi ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid nofailover=On /Location Proxy balancer://mytiti BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2 /Proxy Proxy balancer://mycluster BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto /Proxy +++ 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. Comments? Hmm, nofailover=On is used for non-matched routes. The failover stuff is between the members of a balancer not between balancers. Not true. It returns 500 instead forcing re-login (if there is no session replication or SSO, and that's why it was designed at the first place) It returns 500 forever ;-( It doesn't according to my tests if nofailover=Off or omitted. Regards, Mladen
Re: httpd returns 500 when a route does not belong to the balancer.
Mladen Turk wrote: jean-frederic clere wrote: Mladen Turk wrote: jean-frederic clere wrote: Hi, I would like to fix a problem in mod_proxy_balancer when the configuration is something like: +++ Location /myapp ProxyPass balancer://mycluster/myapp stickysession=JESSSIONID|jsessionid nofailover=On /Location Location /titi ProxyPass balancer://mytiti/titi stickysession=JESSSIONID|jsessionid nofailover=On /Location Proxy balancer://mytiti BalancerMember ajp://jfcpc:8009 smax=10 timeout=10 route=test2 /Proxy Proxy balancer://mycluster BalancerMember ajp://neo:8009 smax=10 timeout=10 route=toto /Proxy +++ 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. Comments? Hmm, nofailover=On is used for non-matched routes. The failover stuff is between the members of a balancer not between balancers. Not true. ? In find_route_worker(proxy_balancer *balancer...) +++ while (!checked_standby) { worker = (proxy_worker *)balancer-workers-elts; for (i = 0; i balancer-workers-nelts; i++, worker++) { +++ That is failover between workers of the balancer, no? Cheers Jean-Frederic It returns 500 instead forcing re-login (if there is no session replication or SSO, and that's why it was designed at the first place) It returns 500 forever ;-( It doesn't according to my tests if nofailover=Off or omitted. Regards, Mladen
Re: httpd returns 500 when a route does not belong to the balancer.
jean-frederic clere wrote: Hmm, nofailover=On is used for non-matched routes. The failover stuff is between the members of a balancer not between balancers. Not true. ? In find_route_worker(proxy_balancer *balancer...) nofailover == sticky_force snip runtime = find_session_route(*balancer, r, route, url); if (runtime) { ... } else if (route (*balancer)-sticky_force) { ... return HTTP_SERVICE_UNAVAILABLE; } /snip So it means that if route doesn't match the runtime will be NULL. However if there is route *and* nofailover=On return HTTP_SERVICE_UNAVAILABLE. By default (nofilover=Off) it will match the URI which might lead to a different balancer or node. nofailover is used to return 503 in case there is miss matching route (session affinity mark), and it's actually a sticky_force, and you cannot have a sticky_force and cross instance sessions without session replication (thus you don't need route) Regards, Mladen.