You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/01/23 21:31:43 UTC

[trafficserver] branch 9.0.x updated: Fixes Issue #6321 caused when proxy.config.http.no_dns_just_forward_to_parent is enabled. When this configuration variable is enabled, a parent selection strategies findParent() function is called twice on each transaction resulting in unexpected results such as every other parent is only used in a strict round robin strategy.

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

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 47c2abd  Fixes Issue #6321 caused when proxy.config.http.no_dns_just_forward_to_parent is enabled.  When this configuration variable is enabled, a parent selection strategies findParent() function is called twice on each transaction resulting in unexpected results such as every other parent is only used in a strict round robin strategy.
47c2abd is described below

commit 47c2abd221985a236b59c1bc53e090b4bb8e5cc4
Author: John Rushford <jr...@apache.org>
AuthorDate: Thu Jan 16 20:01:23 2020 +0000

    Fixes Issue #6321 caused when proxy.config.http.no_dns_just_forward_to_parent
    is enabled.  When this configuration variable is enabled, a parent selection
    strategies findParent() function is called twice on each transaction resulting
    in unexpected results such as every other parent is only used in a strict
    round robin strategy.
    
    (cherry picked from commit 98893b6df4e9acfe68c770ec6c8ef75bcebd0919)
---
 proxy/ParentSelection.cc | 42 ++++++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index 27c52c9..93a0a4c 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -108,12 +108,6 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result, uns
   ParentRecord *defaultPtr = DefaultParent;
   ParentRecord *rec;
 
-  Debug("parent_select", "In ParentConfigParams::findParent(): parent_table: %p.", parent_table);
-  ink_assert(result->result == PARENT_UNDEFINED);
-
-  // Initialize the result structure
-  result->reset();
-
   // Check to see if the parent was set through the
   //   api
   if (apiParentExists(rdata)) {
@@ -128,6 +122,9 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result, uns
     return;
   }
 
+  // Initialize the result structure
+  result->reset();
+
   tablePtr->Match(rdata, result);
   rec = result->rec;
 
@@ -228,17 +225,38 @@ ParentConfigParams::nextParent(HttpRequestData *rdata, ParentResult *result, uns
 bool
 ParentConfigParams::parentExists(HttpRequestData *rdata)
 {
-  unsigned int fail_threshold = policy.FailThreshold;
-  unsigned int retry_time     = policy.ParentRetryTime;
+  P_table *tablePtr = parent_table;
+  ParentRecord *rec = nullptr;
   ParentResult result;
 
-  findParent(rdata, &result, fail_threshold, retry_time);
+  // Initialize the result structure;
+  result.reset();
 
-  if (result.result == PARENT_SPECIFIED) {
-    return true;
-  } else {
+  tablePtr->Match(rdata, &result);
+  rec = result.rec;
+
+  if (rec == nullptr) {
+    Debug("parent_select", "No matching parent record was found for the request.");
     return false;
   }
+
+  if (rec->num_parents > 0) {
+    for (int ii = 0; ii < rec->num_parents; ii++) {
+      if (rec->parents[ii].available) {
+        Debug("parent_select", "found available parent: %s", rec->parents[ii].hostname);
+        return true;
+      }
+    }
+  }
+  if (rec->secondary_parents && rec->num_secondary_parents > 0) {
+    for (int ii = 0; ii < rec->num_secondary_parents; ii++) {
+      if (rec->secondary_parents[ii].available) {
+        Debug("parent_select", "found available parent: %s", rec->secondary_parents[ii].hostname);
+        return true;
+      }
+    }
+  }
+  return false;
 }
 
 int ParentConfig::m_id = 0;