You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jeff Trawick <tr...@gmail.com> on 2012/07/27 01:38:43 UTC

[PATCH] Bug 48735 - bybusyness does not balance after failed worker has recovered

The primary issue is that the busy flag is incremented when the worker
is chosen but, if an error is encountered and another worker selected,
the flag is never decremented.  (The sole decrement in
proxy_balancer_post_request() will be of the worker used to
successfully process the request.)

One of the 2.2.x patches attached to 48735 resets busy and lbstatus to
0 when a worker is recovered.  But it seems rather non-intuitive to
remain busy while in error state.

My alternative for handling the busy flag is to register a request
cleanup at the time the busy flag is incremented to ensure that it is
decremented, no matter what happens on the request.

Index: modules/proxy/mod_proxy_balancer.c
===================================================================
--- modules/proxy/mod_proxy_balancer.c	(revision 1366162)
+++ modules/proxy/mod_proxy_balancer.c	(working copy)
@@ -437,6 +437,17 @@
     }
 }

+static apr_status_t decrement_busy_count(void *worker_)
+{
+    proxy_worker *worker = worker_;
+
+    if (worker->s->busy) {
+        worker->s->busy--;
+    }
+
+    return APR_SUCCESS;
+}
+
 static int proxy_balancer_pre_request(proxy_worker **worker,
                                       proxy_balancer **balancer,
                                       request_rec *r,
@@ -570,6 +581,8 @@
     }

     (*worker)->s->busy++;
+    apr_pool_cleanup_register(r->pool, *worker, decrement_busy_count,
+                              apr_pool_cleanup_null);

     /* Add balancer/worker info to env. */
     apr_table_setn(r->subprocess_env,
@@ -642,11 +655,7 @@
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01176)
                   "proxy_balancer_post_request for (%s)", balancer->s->name);

-    if (worker && worker->s->busy)
-        worker->s->busy--;
-
     return OK;
-
 }

 static void recalc_factors(proxy_balancer *balancer)

thoughts?

concern:

* lbstatus: I haven't learned how lbstatus is manipulated or checked
when/what should be done for a recovered worker; once busy is handled
there's still some bogosity with the "load" as displayed by balancer
manager, so something is needed here

-- 
Born in Roswell... married an alien...
http://emptyhammock.com/

Re: [PATCH] Bug 48735 - bybusyness does not balance after failed worker has recovered

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Jul 26, 2012, at 7:38 PM, Jeff Trawick wrote:
> 
> thoughts?
> 

++1!