Bug 47063

Summary: mod_proxy doesn't call post_request handler when the worker returned by pre_request is unusable
Product: Apache httpd-2 Reporter: Thomas Binder <binder>
Component: mod_proxyAssignee: Apache HTTPD Bugs Mailing List <bugs>
Severity: normal Keywords: MassUpdate
Priority: P2    
Version: 2.2.11   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Patch to call the post_request handler in proxy_handler() before trying a new worker
Patch to fix this problem with another approach
Patch to fix this problem with another approach

Description Thomas Binder 2009-04-21 07:19:40 UTC
Created attachment 23520 [details]
Patch to call the post_request handler in proxy_handler() before trying a new worker

We're running an environment with Apache 2.2.11 acting as reverse proxy for several Apache Tomcat servers, using mod_proxy_balancer and its "bybusyness" method. We've noticed that when one of the backend servers fails during heavy load, it will almost never be used again once it is restored, even though the corresponding worker shows up as "OK" in the balancer manager.

Investigating this a little, I've found that the "busy" counter of the affected worker is a lot greater than zero, causing it to be ignored by the "bybusyness" algorithm unless the proxy is under really heavy load again. I've finally tracked it down to the while loop in mod_proxy.c which tries to find a suitable worker to handle the current request: It calls ap_proxy_pre_request(), which will increase the "busy" counter of the worker returned, but if that worker fails to serve the request, ap_proxy_pre_request() will be called again without calling proxy_run_post_request() for the worker that failed, so that its "busy" counter will never be decremented again.

I've created a small patch to fix this, but as I'm not an Apache hacker, I cannot tell whether it is the right way to fix the issue. At least, it succeeded in fixing the problem in our environment, without causing any unwanted side effects up to now.

While debugging this issue, I've also added a "busyness" column to balancer-handler, which can be found as an attachment to bug #46215.
Comment 1 uta 2009-08-31 01:04:32 UTC
Created attachment 24189 [details]
Patch to fix this problem with another approach

Busyness counter should be reset when the worker is returned to be usable.
Comment 2 uta 2009-08-31 02:44:35 UTC
Created attachment 24190 [details]
Patch to fix this problem with another approach

Busyness counter should be reset when the worker is down.
Comment 3 William A. Rowe Jr. 2018-11-07 21:09:31 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd.

As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd.

If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question.

If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with.

Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.