Skip to content

Commit

Permalink
Work around some mgr:forward accounting/reporting bugs (#1969)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rousskov authored and squid-anubis committed Dec 25, 2024
1 parent 16cafa1 commit 7af4c13
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/FwdState.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1349,26 +1349,34 @@ 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)
{
int i;
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]);
}

Expand Down

0 comments on commit 7af4c13

Please sign in to comment.