]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Work around some mgr:forward accounting/reporting bugs (#1969)
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 31 Dec 2024 21:59:05 +0000 (21:59 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 31 Dec 2024 21:59:10 +0000 (21:59 +0000)
In modern code, FwdReplyCodes[0][i] is usually zero because n_tries is
usually at least one at logReplyStatus() call time. This leads to
mgr:forward report showing nothing but table heading (i.e. no stats)

Also improve `try#N` heading:data match by skipping FwdReplyCodes[0]
reporting (there is still no `try#0` heading) and adding a previously
missing `try#9` heading

src/FwdState.cc

index bbca57e56f6ea16c4f4bd9c50cd56664484b7e6d..3e1a2ce264af7da188ac91db44d95a4c938b96e1 100644 (file)
@@ -1349,6 +1349,8 @@ FwdState::reforward()
     return Http::IsReforwardableStatus(s);
 }
 
+// TODO: Refactor to fix multiple mgr:forward accounting/reporting bugs. See
+// https://lists.squid-cache.org/pipermail/squid-users/2024-December/027331.html
 static void
 fwdStats(StoreEntry * s)
 {
@@ -1356,19 +1358,25 @@ fwdStats(StoreEntry * s)
     int j;
     storeAppendPrintf(s, "Status");
 
-    for (j = 1; j < MAX_FWD_STATS_IDX; ++j) {
+    // XXX: Missing try#0 heading for FwdReplyCodes[0][i]
+    for (j = 1; j <= MAX_FWD_STATS_IDX; ++j) {
         storeAppendPrintf(s, "\ttry#%d", j);
     }
 
     storeAppendPrintf(s, "\n");
 
     for (i = 0; i <= (int) Http::scInvalidHeader; ++i) {
-        if (FwdReplyCodes[0][i] == 0)
+        // XXX: Missing reporting of status codes for which logReplyStatus() was
+        // only called with n_tries exceeding 1. To be more precise, we are
+        // missing (the equivalent of) logReplyStatus() calls for attempts done
+        // outside of FwdState. Relying on n_tries<=1 counters is too fragile.
+        if (!FwdReplyCodes[0][i] && !FwdReplyCodes[1][i])
             continue;
 
         storeAppendPrintf(s, "%3d", i);
 
-        for (j = 0; j <= MAX_FWD_STATS_IDX; ++j) {
+        // XXX: Missing FwdReplyCodes[0][i] reporting
+        for (j = 1; j <= MAX_FWD_STATS_IDX; ++j) {
             storeAppendPrintf(s, "\t%d", FwdReplyCodes[j][i]);
         }