Repository navigation
Count retried cluster redirects once in completion statistics - #582
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. I went through the stats changes and the new fixture. The core change looks right to me: every MOVED/ASK still increments the redirect counter, but bytes, latency and Count only land once, either on the terminal redirect or on the final reply via A few comments:
The fix itself looks solid. I'd mainly like the |
|
Checked these points against the current code:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3a32c8c. Configure here.
|
Adversarial review summary. 7 independent reviewers looked at correctness, output compatibility, test discrimination, build and sanitizers, lifetime, interactions with #574/#575/#576/#583/#578, and maintainer standards. All 7 gave MERGE.
Non-blocking follow-ups (test gaps found by mutation testing):
Pre-existing, out of scope:
🤖 Generated with Claude Code |
Mutation testing during the review of #582 and #583 found faults that the merged tests did not catch. This change only touches tests. test_cluster_redirect_stats.py (#582, #579): - Check the Totals Time-Serie Count, Bytes RX and Bytes TX as well as the per-command series. Dropping m_total_cmd.update_op() in update_moved_set_op() used to pass. - Delay every terminal reply from the scripted peer by 20 ms, and check Min/Average/p50 latency and each per-second Min Latency against that delay in every mode. A zero latency on a completed redirect (for example an ASK reply with retries disabled) used to pass the default-backoff cases. - Report Ops/sec == 0 as an assertion instead of letting the redirect-rate division raise ZeroDivisionError and skip the remaining cases. - Check the final errors/retries/retried_ops progress counters on the success, refused and transaction paths. cluster_transaction_test.cpp (#583, #580): - Add a two-shard test with a populated slot map. After txn_release_pin(), the next send must re-pin to the owner of the retained lookahead key. Generating the key after it used to pass. - After releasing a pin whose round key was already consumed, check that the round key and the pin are both cleared. The existing "pin and old round key released" check runs before any round key is set, so it cannot fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mutation testing during the review of #582 and #583 found faults that the merged tests did not catch. This change only touches tests. test_cluster_redirect_stats.py (#582, #579): - Check the Totals Time-Serie Count, Bytes RX and Bytes TX as well as the per-command series. Dropping m_total_cmd.update_op() in update_moved_set_op() used to pass. - Delay every terminal reply from the scripted peer by 20 ms, and check Min/Average/p50 latency and each per-second Min Latency against that delay in every mode. A zero latency on a completed redirect (for example an ASK reply with retries disabled) used to pass the default-backoff cases. - Run the success mode with a 50 ms backoff too, and require each sample to cover both backoffs. Timing the reply from the last send instead of the first (m_sent_time in client::handle_response) used to pass. - Check the final errors/retries/retried_ops progress counters on the success, refused and transaction paths. The stderr progress line is the only output that carries them. cluster_transaction_test.cpp (#583, #580): - Add a two-shard test with a populated slot map. After txn_release_pin(), the next send must re-pin to the owner of the retained lookahead key. Generating the key after it used to pass. - After releasing a pin whose round key was already consumed, check that the round key and the pin are both cleared. The existing "pin and old round key released" check runs before any round key is set, so it cannot fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mutation testing during the review of #582 and #583 found faults that the merged tests did not catch. This change only touches tests. test_cluster_redirect_stats.py (#582, #579): - Check the Totals Time-Serie Count, Bytes RX and Bytes TX as well as the per-command series. Dropping m_total_cmd.update_op() in update_moved_set_op() used to pass. - Delay every terminal reply from the scripted peer by 20 ms, and check Min/Average/p50 latency and each per-second Min Latency against that delay in every mode. A zero latency on a completed redirect (for example an ASK reply with retries disabled) used to pass the default-backoff cases. - Run the success mode with a 50 ms backoff too, and require each sample to cover both backoffs. Timing the reply from the last send instead of the first (m_sent_time in client::handle_response) used to pass. - Check the final errors/retries/retried_ops progress counters on the success, refused and transaction paths. The stderr progress line is the only output that carries them. cluster_transaction_test.cpp (#583, #580): - Add a two-shard test with a populated slot map. After txn_release_pin(), the next send must re-pin to the owner of the retained lookahead key. Generating the key after it used to pass. - After releasing a pin whose round key was already consumed, check that the round key and the pin are both cleared. The existing "pin and old round key released" check runs before any round key is set, so it cannot fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mutation testing during the review of #582 and #583 found faults that the merged tests did not catch. This change only touches tests. test_cluster_redirect_stats.py (#582, #579): - Check the Totals Time-Serie Count, Bytes RX and Bytes TX as well as the per-command series. Dropping m_total_cmd.update_op() in update_moved_set_op() used to pass. - Delay every terminal reply from the scripted peer by 20 ms, and check Min/Average/p50 latency and each per-second Min Latency against that delay in every mode. A zero latency on a completed redirect (for example an ASK reply with retries disabled) used to pass the default-backoff cases. - Run the success mode with a 50 ms backoff too, and require each sample to cover both backoffs. Timing the reply from the last send instead of the first (m_sent_time in client::handle_response) used to pass. - Check the final errors/retries/retried_ops progress counters on the success, refused and transaction paths. The stderr progress line is the only output that carries them. cluster_transaction_test.cpp (#583, #580): - Add a two-shard test with a populated slot map. After txn_release_pin(), the next send must re-pin to the owner of the retained lookahead key. Generating the key after it used to pass. - After releasing a pin whose round key was already consumed, check that the round key and the pin are both cleared. The existing "pin and old round key released" check runs before any round key is set, so it cannot fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>

With
--cluster-mode --retry-on-error, a request receiving MOVED or ASK contributed an operation, bytes, and a latency sample both for the redirect and for its final reply. A deterministic 12-request run with two redirects per request reported 36 operations and histogram samples.Record every MOVED/ASK event, but count completion statistics only when the redirect is terminal or the retried request receives its final reply. Disabled retries, exhausted retries, and transaction redirects retain terminal accounting. Terminal redirect latency spans the first send through the final outcome, including retries and backoff, consistent with successful requests. READONLY handling is unchanged.
Validation:
Fixes #579.
Note
Medium Risk
Changes benchmark accounting and latency semantics for cluster redirects under retry, which can shift reported ops/sec and histograms for existing cluster workloads.
Overview
Fixes double-counting of cluster MOVED/ASK responses when
--retry-on-erroris enabled: each redirect used to add an operation, byte totals, and a latency sample in addition to the final successful reply.Cluster client now routes redirect accounting through
update_redirect_stats, which always increments MOVED/ASK counters but only records completion stats (Count, bytes, histograms) when the redirect is terminal (completed)—i.e. retry disabled, retry refused/exhausted,--transactiondrop, or no retry queued. Terminal latency usesm_first_sent_timethrough the final outcome (including backoff).handle_movedis limited to topology refresh;handle_askis removed in favor of the shared stats path.run_statsgains acompletedflag on all moved/ask updaters and drops the separateupdate_moved_op/update_ask_ophelpers. A deterministic integration test (test_cluster_redirect_stats.py) validates counts, histogram samples, bytes, and redirect rates; failover retry test expects an exact op total. ASan/TSan/UBSan workflows include the new test.Reviewed by Cursor Bugbot for commit d7aa2c6. Bugbot is set up for automated code reviews on this repo. Configure here.