httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@gmail.com>
Subject [PATCH] Bug 48735 - bybusyness does not balance after failed worker has recovered
Date Thu, 26 Jul 2012 23:38:43 GMT
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/

Mime
View raw message