You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ez...@apache.org on 2022/04/13 00:37:19 UTC

[trafficserver] branch master updated: Add PS debug to store requesting URL and add to notes (#8049)

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

eze pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 3265b820a Add PS debug to store requesting URL and add to notes (#8049)
3265b820a is described below

commit 3265b820afc1695ef8067b04d1c0aa8d1e2796fb
Author: Evan Zelkowitz <ez...@apache.org>
AuthorDate: Tue Apr 12 18:37:12 2022 -0600

    Add PS debug to store requesting URL and add to notes (#8049)
    
    * Add PS debug to store requesting URL and add to notes
    
    Parent mark down/up does not currently log the url of the request that caused the marking. This makes it hard to debug production issues when you have multiple parents and dest_domains being used, there is not a way currently to know which of them may be having an issue since the URL is not logged.
    This adds a reference the requests http string, which is then used in the mark down/up notes that print out
    
    * Switching to using the hostname string. There is not a good place to do a free on the url string that I could see, but the hostname string provides almost the same functionality and is allocated within the SM or transact and not within the get_host function
---
 proxy/ParentSelection.cc         | 12 ++++++------
 proxy/ParentSelection.h          |  1 +
 proxy/ParentSelectionStrategy.cc | 10 +++++-----
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index 8c0b54e07..0f495f1af 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -115,6 +115,7 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result, uns
     result->rec          = extApiRecord;
     result->start_parent = 0;
     result->last_parent  = 0;
+    result->url          = rdata->get_host();
 
     Debug("parent_select", "Result for %s was API set parent %s:%d", rdata->get_host(), result->hostname, result->port);
     return;
@@ -124,7 +125,8 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result, uns
   result->reset();
 
   tablePtr->Match(rdata, result);
-  rec = result->rec;
+  rec         = result->rec;
+  result->url = rdata->get_host();
 
   if (rec == nullptr) {
     // No parents were found
@@ -143,23 +145,21 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result, uns
     selectParent(true, result, rdata, fail_threshold, retry_time);
   }
 
-  const char *host = rdata->get_host();
-
   switch (result->result) {
   case PARENT_UNDEFINED:
     Debug("parent_select", "PARENT_UNDEFINED");
-    Debug("parent_select", "Result for %s was %s", host, ParentResultStr[result->result]);
+    Debug("parent_select", "Result for %s was %s", result->url, ParentResultStr[result->result]);
     break;
   case PARENT_FAIL:
     Debug("parent_select", "PARENT_FAIL");
     break;
   case PARENT_DIRECT:
     Debug("parent_select", "PARENT_DIRECT");
-    Debug("parent_select", "Result for %s was %s", host, ParentResultStr[result->result]);
+    Debug("parent_select", "Result for %s was %s", result->url, ParentResultStr[result->result]);
     break;
   case PARENT_SPECIFIED:
     Debug("parent_select", "PARENT_SPECIFIED");
-    Debug("parent_select", "Result for %s was parent %s:%d", host, result->hostname, result->port);
+    Debug("parent_select", "Result for %s was parent %s:%d", result->url, result->hostname, result->port);
     break;
   default:
     // Handled here:
diff --git a/proxy/ParentSelection.h b/proxy/ParentSelection.h
index 69d20241f..aaf7d23ef 100644
--- a/proxy/ParentSelection.h
+++ b/proxy/ParentSelection.h
@@ -187,6 +187,7 @@ struct ParentResult {
   // For outside consumption
   ParentResultType result;
   const char *hostname;
+  const char *url;
   int port;
   bool retry;
   bool chash_init[MAX_GROUP_RINGS] = {false};
diff --git a/proxy/ParentSelectionStrategy.cc b/proxy/ParentSelectionStrategy.cc
index f3101ccc0..c0fbecdd9 100644
--- a/proxy/ParentSelectionStrategy.cc
+++ b/proxy/ParentSelectionStrategy.cc
@@ -67,8 +67,8 @@ ParentSelectionStrategy::markParentDown(ParentResult *result, unsigned int fail_
       new_fail_count = pRec->failCount = 1;
     }
 
-    Note("Parent %s marked as down %s:%d", (result->retry) ? "retry" : "initially", pRec->hostname, pRec->port);
-
+    Note("Parent %s marked as down %s:%d for request %s", (result->retry) ? "retry" : "initially", pRec->hostname, pRec->port,
+         result->url);
   } else {
     int old_count = 0;
     now           = time(nullptr);
@@ -88,8 +88,8 @@ ParentSelectionStrategy::markParentDown(ParentResult *result, unsigned int fail_
   }
 
   if (new_fail_count > 0 && new_fail_count >= static_cast<int>(fail_threshold)) {
-    Note("Failure threshold met failcount:%d >= threshold:%d, http parent proxy %s:%d marked down", new_fail_count, fail_threshold,
-         pRec->hostname, pRec->port);
+    Note("Failure threshold met failcount:%d >= threshold:%d, http parent proxy %s:%d marked down with request: %s", new_fail_count,
+         fail_threshold, pRec->hostname, pRec->port, result->url);
     pRec->available = false;
     Debug("parent_select", "Parent %s:%d marked unavailable, pRec->available=%d", pRec->hostname, pRec->port,
           pRec->available.load());
@@ -125,6 +125,6 @@ ParentSelectionStrategy::markParentUp(ParentResult *result)
   // a retry succeeded, just reset retriers
 
   if (old_count > 0) {
-    Note("http parent proxy %s:%d restored", pRec->hostname, pRec->port);
+    Note("http parent proxy %s:%d restored with request %s", pRec->hostname, pRec->port, result->url);
   }
 }