ywkaras commented on code in PR #9620:
URL: https://github.com/apache/trafficserver/pull/9620#discussion_r1177064453


##########
proxy/http/HttpTransact.h:
##########
@@ -944,7 +944,22 @@ class HttpTransact
     MgmtInt
     configured_connect_attempts_max_retries() const
     {
-      return txn_conf->connect_attempts_max_retries;
+      if (dns_info.looking_up != ResolveInfo::PARENT_PROXY) {
+        return txn_conf->connect_attempts_max_retries;
+      }
+      // For parent proxy, return the maximum attempt count for the current
+      // parent intead of the global max retries for the whole parent group.
+      // The max attempt count for the current parent is calculated by rounding
+      // the current attempt up to next multiple of ppca.
+      auto ppca                    = txn_conf->per_parent_connect_attempts;
+      auto cur_attempts            = current.attempts.get();
+      auto cur_parent_max_attempts = ((cur_attempts + ppca - 1) / ppca) * ppca;
+      if (cur_attempts == cur_parent_max_attempts) {
+        // If the current attempt is already a multiple of ppca, get the next
+        // multiple.
+        cur_parent_max_attempts += ppca;
+      }

Review Comment:
   How about?
   ```
       MgmtInt
       configured_connect_attempts_max_retries() const
       {
         if (parent_params != nullptr) {
           auto ppca = txn_conf->per_parent_connect_attempts;
           auto tries = current.attempts.get() + 1;
           // Round g up to next multiple of ppca.
           auto ru = ((tries + ppca - 1) / ppca) * ppca;
           return std::min(ru, txn_conf->parent_connect_attempts) - 1;
         }
         return txn_conf->connect_attempts_max_retries;
       }
   ```
   But this would also require removing the parameter and assert in 
`CurrentInfo::Attempts::increment()`, 
   and changing line 3644 in HttpTransact.cc to:
   ```
       if (s->current.attempts.get() < (s->txn_conf->parent_connect_attempts - 
1)) {
   ```
   and changing line 3649 in HttpTransact.cc to:
   ```
         if (s->current.attempts.get() % 
s->txn_conf->per_parent_connect_attempts != 0) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to