]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r451572 from trunk:
authorRuediger Pluem <rpluem@apache.org>
Sat, 15 Nov 2008 14:16:23 +0000 (14:16 +0000)
committerRuediger Pluem <rpluem@apache.org>
Sat, 15 Nov 2008 14:16:23 +0000 (14:16 +0000)
Add force recovery for balancer.
In case all balancer members were in error state 503
was returned until the recovery timeout expired.
The patch forces recovery in case all balancer members
are in error state regardless of recovery timeout
directive.
This fixes the time gap when 503 was returned and
backend was already up and running.

Submitted by: mturk
Reviewed by: jim, rpluem, jfclere

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@714270 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/proxy/mod_proxy_balancer.c

diff --git a/CHANGES b/CHANGES
index c8717f8cda393125086ece31fc39afd07708715f..e42a1d03cea66c3401b70fb5be626b27eb649d4a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.2.11
 
+  *) mod_proxy_balancer: Add in forced recovery for balancer members if
+     all are in error state. [Mladen Turk]
+
   *) mod_proxy: Prevent segmentation faults by correctly adjusting the
      lifetime of the buckets read from the proxy backend. PR 45792
      [Ruediger Pluem]
diff --git a/STATUS b/STATUS
index 99782c0e8b98360ad542b40bbb9dd73ff26afa57..572bafb68ee1cdf0ed5d05d849cc673d39c82f2e 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -85,14 +85,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   * mod_proxy_balancer: Add in forced recovery for balancer
-     members if all are in error state.
-     Trunk version of patch:
-        http://svn.apache.org/viewcvs.cgi?rev=451572&view=rev
-     Backport version for 2.2.x of patch:
-        http://people.apache.org/~jim/patches/proxy-force-recovery.patch.txt
-     +1: jim, rpluem, jfclere
-
     * mod_proxy_ajp: Do not fail if response data is sent before all request
       data is read.  PR 45911
       Trunk version of patch:
index 04ed09bd9e376d8f641bf986755d4c9dffe06100..c0dc2af975ccec4c8e92517ebc19f701dd34eab5 100644 (file)
@@ -396,6 +396,33 @@ static int rewrite_url(request_rec *r, proxy_worker *worker,
     return OK;
 }
 
+static void force_recovery(proxy_balancer *balancer, server_rec *s)
+{
+    int i;
+    int ok = 0;
+    proxy_worker *worker;
+
+    worker = (proxy_worker *)balancer->workers->elts;
+    for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+        if (!(worker->s->status & PROXY_WORKER_IN_ERROR)) {
+            ok = 1;
+            break;    
+        }
+    }
+    if (!ok) {
+        /* If all workers are in error state force the recovery.
+         */
+        worker = (proxy_worker *)balancer->workers->elts;
+        for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+            ++worker->s->retries;
+            worker->s->status &= ~PROXY_WORKER_IN_ERROR;
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
+                         "proxy: BALANCER: (%s). Forcing recovery for worker (%s)",
+                         balancer->name, worker->hostname);
+        }
+    }
+}
+
 static int proxy_balancer_pre_request(proxy_worker **worker,
                                       proxy_balancer **balancer,
                                       request_rec *r,
@@ -417,10 +444,7 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
         !(*balancer = ap_proxy_get_balancer(r->pool, conf, *url)))
         return DECLINED;
 
-    /* Step 2: find the session route */
-
-    runtime = find_session_route(*balancer, r, &route, &sticky, url);
-    /* Lock the LoadBalancer
+    /* Step 2: Lock the LoadBalancer
      * XXX: perhaps we need the process lock here
      */
     if ((rv = PROXY_THREAD_LOCK(*balancer)) != APR_SUCCESS) {
@@ -429,6 +453,12 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
                      (*balancer)->name);
         return DECLINED;
     }
+
+    /* Step 3: force recovery */
+    force_recovery(*balancer, r->server);
+
+    /* Step 4: find the session route */
+    runtime = find_session_route(*balancer, r, &route, &sticky, url);
     if (runtime) {
         int i, total_factor = 0;
         proxy_worker *workers;