Skip to content

Count arbitrary-command redirects in Totals MOVED/sec and ASK/sec - #594

Merged
fcostaoliveira merged 2 commits into
masterfrom
fix/totals-redirects-arbitrary
Oct 14, 2026
Merged

fcostaoliveira merged 2 commits into
masterfrom
fix/totals-redirects-arbitrary

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

In --cluster-mode with --command, the Totals row reports MOVED/sec and ASK/sec as 0.00 while the per-command rows show redirects. This affects the text table, the JSON Totals object and the --run-count AGGREGATED AVERAGE Totals.

Root cause

run_stats::summarize() computed the Totals redirect rates from m_set_cmd + m_get_cmd only. Ops, bytes and latency in the same function also include m_ar_commands, but the redirect rates did not. aggregate_average() averages the per-run summarize() results, so the AVERAGE Totals inherited the 0.

Fix

Read the Totals rates from m_total_cmd.m_moved / m_ask. Every redirect path (update_moved_{get,set,arbitrary}_op, update_ask_*) already increments m_total_cmd next to the per-command counter, and m_total_cmd is also what the Totals time series is built from. For the default SET/GET workload the value is unchanged (WAIT never redirects).

tests/test_cluster_redirect_stats.py skipped the Totals rate check for arbitrary-* commands to work around this bug. The workaround is removed, so Totals is now checked for every command, redirect type and retry mode.

Other outputs checked: the JSON Time-Serie entries carry no MOVED/ASK fields, so they have no such gap. The --client-stats CSV has a per-second cluster section only for the default workload, so with --command it has no redirect data at all. That is a separate missing feature and is not changed here.

Test evidence

test_cluster_redirect_stats.py uses a scripted RESP peer, so the results are deterministic. Totals is now checked in three places:

  • the JSON ALL STATS Totals, for every command, redirect type and retry mode;
  • the text Totals row, which must match the command row and be non-zero;
  • a new --run-count=2 case: the AGGREGATED AVERAGE RESULTS (2 runs) Totals MOVED/sec and ASK/sec must equal the command row, and redirects per op must equal the known count.

A zero Ops/sec is reported as a failure instead of raising, so the remaining cases still run.

Binary Result (5 tests)
origin/master 5/5 FAIL (Totals 0.00 vs the command row, JSON and text)
this branch PASS in 9/9 clean runs
mutant: m_totals.m_moved_sec /= all_stats.size() deleted test_run_count_average_redirect_stats FAILS (AVERAGE Totals 1052.60 vs 526.30, redirects per op 4.0 vs 2)
mutant: text Totals MOVED cell back to m_set_cmd + m_get_cmd 4/5 FAIL (text Totals 0.00 vs 37.65 for --command; the ASK-only test passes, as expected)

Manual run against the same peer (--command="SET __key__ value", 24 MOVED replies):

master:  Sets MOVED/sec 740.22   Totals 0.00
fix:     Sets MOVED/sec 668.08   Totals 668.08
--run-count 2, AVERAGE: master Totals 0.00, fix Totals 402.24 (= Sets)

Fixes #589

Affected versions

2.0.0 through 2.5.2 (latest) and master. Introduced by 1c6735f (#117), first tag 2.0.0. Confirmed by running on 2.0.0, 2.4.0, 2.5.2 and master e4d14e8. 2.1.0–2.3.1, 2.4.1–2.4.4 and 2.5.0–2.5.1 are derived from history.

🤖 Generated with Claude Code

fcostaoliveira and others added 2 commits October 14, 2026 01:59
summarize() built the Totals redirect rates from the SET and GET
counters only, while ops, bytes and latency in the same function also
include m_ar_commands. In cluster mode with --command, Totals MOVED/sec
and ASK/sec were therefore always 0.00 in the text table, the JSON
Totals and the --run-count AVERAGE, while the per-command rows showed
the redirects.

Read the rates from m_total_cmd instead. Every redirect path already
increments m_total_cmd next to the per-command counter, and it is what
the Totals time series is built from.

test_cluster_redirect_stats.py skipped the Totals rate check for
arbitrary commands to work around this; check it for every command now.

Fixes #589

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The JSON ALL STATS check alone missed two regressions: dropping the
m_moved_sec/m_ask_sec average in aggregate_average(), and printing the
text Totals cell from the SET + GET rates again.

Add a --run-count=2 case that checks the AGGREGATED AVERAGE Totals
MOVED/sec and ASK/sec against the command row and the known redirects
per request, and check in every case that the text Totals row matches
the command row with a non-zero rate. A zero Ops/sec is now reported as
a failure instead of raising, so the remaining cases still run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cluster --command: Totals MOVED/sec and ASK/sec always 0.00

1 participant