You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2016/11/02 22:57:48 UTC

[trafficserver] branch 6.2.x updated: TS-4942: simple retry is not working correctly.

This is an automated email from the ASF dual-hosted git repository.

sorber pushed a commit to branch 6.2.x
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/6.2.x by this push:
       new  74fe7c1   TS-4942: simple retry is not working correctly.
74fe7c1 is described below

commit 74fe7c1a333a572a961ce1aff54eddeae2d129dd
Author: John J. Rushford <jr...@apache.org>
AuthorDate: Fri Oct 7 17:29:20 2016 +0000

    TS-4942: simple retry is not working correctly.
    
    (cherry picked from commit 1fdc8ab1f229e8c6d00b34bcd64fff23c9c01ddf)
    
    conflicts resolved.
    
    Conflicts:
    	proxy/http/HttpTransact.cc
---
 proxy/http/HttpTransact.cc | 91 ++++++++++++++++++++++++----------------------
 1 file changed, 48 insertions(+), 43 deletions(-)

diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index ba5dbfe..58b3fcd 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -3570,27 +3570,8 @@ HttpTransact::handle_response_from_parent(State *s)
     break;
   default: {
     LookingUp_t next_lookup = UNDEFINED_LOOKUP;
-    DebugTxn("http_trans", "[hrfp] connection not alive");
-    SET_VIA_STRING(VIA_DETAIL_PP_CONNECT, VIA_DETAIL_PP_FAILURE);
 
-    ink_assert(s->hdr_info.server_request.valid());
-
-    s->current.server->connect_result = ENOTCONN;
-
-    char addrbuf[INET6_ADDRSTRLEN];
-    DebugTxn("http_trans", "[%d] failed to connect to parent %s", s->current.attempts,
-             ats_ip_ntop(&s->current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
-
-    // If the request is not retryable, just give up!
-    if (!is_request_retryable(s)) {
-      s->parent_params->markParentDown(&s->parent_result);
-      s->parent_result.result = PARENT_FAIL;
-      handle_parent_died(s);
-      return;
-    }
-
-    // try a simple retry if we received a simple retryable response from the parent.
-    if (s->current.retry_type == PARENT_RETRY_SIMPLE || s->current.retry_type == PARENT_RETRY_UNAVAILABLE_SERVER) {
+    if (s->current.state == PARENT_ORIGIN_RETRY) {
       if (s->current.retry_type == PARENT_RETRY_SIMPLE) {
         if (s->current.simple_retry_attempts >= s->parent_result.max_retries(PARENT_RETRY_SIMPLE)) {
           DebugTxn("http_trans", "PARENT_RETRY_SIMPLE: retried all parents, send error to client.");
@@ -3601,7 +3582,7 @@ HttpTransact::handle_response_from_parent(State *s)
           s->current.retry_type = PARENT_RETRY_NONE;
           next_lookup           = find_server_and_update_current_info(s);
         }
-      } else { // try unavailable server retry if we have a unavailable server retry response from the parent.
+      } else if (s->current.retry_type == PARENT_RETRY_UNAVAILABLE_SERVER) {
         if (s->current.unavailable_server_retry_attempts >= s->parent_result.max_retries(PARENT_RETRY_UNAVAILABLE_SERVER)) {
           DebugTxn("http_trans", "PARENT_RETRY_UNAVAILABLE_SERVER: retried all parents, send error to client.");
           s->current.retry_type = PARENT_RETRY_NONE;
@@ -3613,35 +3594,59 @@ HttpTransact::handle_response_from_parent(State *s)
           next_lookup = find_server_and_update_current_info(s);
         }
       }
-    } else if (s->current.attempts < s->txn_conf->parent_connect_attempts) {
-      s->current.attempts++;
+    } else {
+      DebugTxn("http_trans", "[hrfp] connection not alive");
+      SET_VIA_STRING(VIA_DETAIL_PP_CONNECT, VIA_DETAIL_PP_FAILURE);
 
-      // Are we done with this particular parent?
-      if ((s->current.attempts - 1) % s->http_config_param->per_parent_connect_attempts != 0) {
-        // No we are not done with this parent so retry
-        s->next_action = how_to_open_connection(s);
-        DebugTxn("http_trans", "%s Retrying parent for attempt %d, max %" PRId64, "[handle_response_from_parent]",
-                 s->current.attempts, s->http_config_param->per_parent_connect_attempts);
+      ink_assert(s->hdr_info.server_request.valid());
+
+      s->current.server->connect_result = ENOTCONN;
+      s->state_machine->do_hostdb_update_if_necessary();
+
+      char addrbuf[INET6_ADDRSTRLEN];
+      DebugTxn("http_trans", "[%d] failed to connect to parent %s", s->current.attempts,
+               ats_ip_ntop(&s->current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
+
+      // If the request is not retryable, just give up!
+      if (!is_request_retryable(s)) {
+        s->parent_params->markParentDown(&s->parent_result);
+        s->parent_result.result = PARENT_FAIL;
+        handle_parent_died(s);
         return;
-      } else {
-        DebugTxn("http_trans", "%s %d per parent attempts exhausted", "[handle_response_from_parent]", s->current.attempts);
+      }
+
+      if (s->current.attempts < s->txn_conf->parent_connect_attempts) {
+        s->current.attempts++;
+
+        // Are we done with this particular parent?
+        if ((s->current.attempts - 1) % s->http_config_param->per_parent_connect_attempts != 0) {
+          // No we are not done with this parent so retry
+          s->next_action = how_to_open_connection(s);
+          DebugTxn("http_trans", "%s Retrying parent for attempt %d, max %" PRId64, "[handle_response_from_parent]",
+                   s->current.attempts, s->http_config_param->per_parent_connect_attempts);
+          return;
+        } else {
+          DebugTxn("http_trans", "%s %d per parent attempts exhausted", "[handle_response_from_parent]", s->current.attempts);
 
-        // Only mark the parent down if we failed to connect
-        //  to the parent otherwise slow origin servers cause
-        //  us to mark the parent down
+          // Only mark the parent down if we failed to connect
+          //  to the parent otherwise slow origin servers cause
+          //  us to mark the parent down
+          if (s->current.state == CONNECTION_ERROR) {
+            s->parent_params->markParentDown(&s->parent_result);
+          }
+          // We are done so look for another parent if any
+          next_lookup = find_server_and_update_current_info(s);
+        }
+      } else {
+        // Done trying parents... fail over to origin server if that is
+        //   appropriate
+        DebugTxn("http_trans", "[handle_response_from_parent] Error. No more retries.");
         if (s->current.state == CONNECTION_ERROR) {
           s->parent_params->markParentDown(&s->parent_result);
         }
-        // We are done so look for another parent if any
-        next_lookup = find_server_and_update_current_info(s);
+        s->parent_result.result = PARENT_FAIL;
+        next_lookup             = find_server_and_update_current_info(s);
       }
-    } else {
-      // Done trying parents... fail over to origin server if that is
-      //   appropriate
-      DebugTxn("http_trans", "[handle_response_from_parent] Error. No more retries.");
-      s->parent_params->markParentDown(&s->parent_result);
-      s->parent_result.result = PARENT_FAIL;
-      next_lookup             = find_server_and_update_current_info(s);
     }
 
     // We have either tried to find a new parent or failed over to the

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].