Skip to content

Close redirect stats and transaction re-pin test gaps from #582 and #583 - #598

Merged
fcostaoliveira merged 1 commit into
masterfrom
test/redirect-and-txn-pin-gaps
Oct 14, 2026
Merged

fcostaoliveira merged 1 commit into
masterfrom
test/redirect-and-txn-pin-gaps

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

These are follow-ups to the adversarial reviews of #582 (MOVED/ASK accounting, #579) and #583 (keeping the transaction lookahead key after a pin release, #580). Mutation testing found mutants that the merged tests did not catch. This PR only changes tests. No product code changes, and no new bug was found.

Gaps closed

# Gap Change Mutant now killed
1 #582: the Time-Serie checks only covered the per-command entry Count, Bytes RX and Bytes TX are now checked for Totals → Time-Serie too M1: delete m_cur_stats.m_total_cmd.update_op(...) in update_moved_set_op
2 #582: latency values were only checked on the exhausted-backoff path The scripted peer delays every terminal reply by 20 ms (success, or the redirect that ends the request). Every case checks Min, Average and p50 latency, plus each per-second Min Latency, against that delay M2: latency = 0 on the completed path of update_ask_get_op
3 A request that succeeds after retries was not timed from its first send New test_retried_success_latency_includes_backoff: success mode with --retry-backoff-ms=50, with a floor of 0.9 × 2 × backoff M7: ref_sent = request->m_sent_time instead of m_first_sent_time in client::handle_response (client.cpp:830)
4 #582 (optional item): the error count was not checked The final errors / retries / retried_ops progress counters are checked on the success, refused and transaction paths. The JSON has no such counters, so the test reads them from the stderr progress line, and a comment marks the regex as tied to that format. In transaction mode a redirected transaction is not retried, so the expected values are errors = requests, retries = 0, retried_ops = 0 M5: drop m_stats.inc_error() in the cluster redirect-failure path
5 #583: re-pin routing was not checked New check_repin_routes_to_staged_owner: two shard connections, a populated slot map, and only the staged key's slot owned by shard 1. After txn_release_pin() and the next send, pin() must equal the owner of the staged key. The test also checks that the owner then consumes that key M3: generate_key(staged_key_index + 1)
6 #583: the "pin and old round key released" check could never fail, because no round key existed yet when it ran Added check(!client.round_key_valid() && client.pin() == -1, ...) after the release-after-consumption step M4: remove m_txn_round_key_valid = false; in txn_release_pin()

The Ops/sec zero guard, and the removal of the old arbitrary- exclusion from the Totals redirect-rate check, come from #594 and are already on master. This PR builds on them and does not change them.

In the unit test, the second shard connection dials a local listening socket. The event loop never runs, so that connection stays conn_in_progress, which means "not disconnected". The test computes slots with an in-test CRC16 and checks it against CLUSTER KEYSLOT foo = 12182. It also checks that the neighbouring key hashes to a different slot, so M3 really does change the routing.

Evidence

Each mutant was injected into the source, rebuilt, and run against this PR's tests and against the tests on master. The mutant was reverted afterwards.

Mutant This PR Tests on master
M1 Totals update_op dropped FAIL: 0 == 12 Count, 0 == 312 Bytes RX, 0 == 804 Bytes TX [MOVED disabled/refused set Totals Time-Serie] pass (survives)
M2 latency = 0 in update_ask_get_op FAIL: 0.008 >= 18.0 Min, 0.0 >= 18.0 series Min [ASK disabled get], [ASK refused get] test_ask_redirect_stats passes (survives). Note: master's test_exhausted_redirect_latency_includes_backoff already catches it, but only on ASK refused get with a 50 ms backoff. The no-retry (disabled) completed path was not covered.
M7 m_sent_time at client.cpp:830 FAIL in all 8 cases (MOVED/ASK × set/get/arbitrary-set/arbitrary-get), e.g. 20.224 >= 90.0 [MOVED success set] the other 5 tests in the file all pass (survives)
M3 generate_key(staged_key_index + 1) FAIL: re-pin routes to the owner of the staged key (#580) pass (survives)
M4 no m_txn_round_key_valid = false FAIL: release after consumption drops pin and round key pass (survives)
M5 no inc_error() FAIL: 0 == 12 [MOVED refused set/get/arbitrary-set/arbitrary-get errors] pass (survives)

M1–M5 were measured on master e4d14e8, before the rebases. M7 was measured on f548ae7.

On master f548ae7 (includes #594 and #601):

  • test_cluster_redirect_stats.py passes 6/6 tests in each of 3 runs, about 100 s per run. The new success-backoff test adds about 20 s to Count arbitrary-command redirects in Totals MOVED/sec and ASK/sec #594's roughly 80 s for 5 tests.
  • cluster_transaction_test passes. Before the rebases it also passed 100/100 runs and was clean under ASan and UBSan.
  • make format-check-staged passes.

Against a binary built at a388a86 (before #594): the merged test file fails 5/5 tests. All 152 failure lines come from arbitrary-* cases, and there are none for set or get. So it catches #589 directly, for example 0.0 almost equels 12 (delta 0.05) [MOVED disabled arbitrary-set] from the JSON Totals ratio check.

Rebase notes

Refs #582, #583, #579, #580, #589, #594.

🤖 Generated with Claude Code


Note

Low Risk
Only test files change; behavior under test is unchanged and risk is limited to CI/runtime of the expanded integration suite.

Overview
Test-only follow-up to #582/#583 mutation-testing gaps. No production code changes.

test_cluster_redirect_stats.py makes MOVED/ASK accounting stricter: the scripted peer adds a fixed 20 ms delay on every terminal reply so Min/Average/p50 (and per-second Min in Time-Serie) can be bounded for success, refused, and completed paths—not only exhausted-backoff cases. It parses the final stderr errors / retries / retried_ops line (regex-tied to progress format) for success, refused, and transaction modes. Time-Serie Count, Bytes RX/TX, and latency checks now run for Totals as well as per-command stats. New test_retried_success_latency_includes_backoff asserts success-after-two-redirects latency includes both backoffs (50 ms).

cluster_transaction_test.cpp refactors transaction setup helpers and extends transaction_client with send_from, two-shard route_slot_to_second_shard, and an in-test CRC16 slot helper. check_repin_routes_to_staged_owner verifies re-pin after txn_release_pin() routes to the staged key’s shard owner (#580). check_pin_release adds an assertion that release-after-consumption clears pin and round key.

Reviewed by Cursor Bugbot for commit b1214ba. Bugbot is set up for automated code reviews on this repo. Configure here.

@fcostaoliveira
fcostaoliveira force-pushed the test/redirect-and-txn-pin-gaps branch 2 times, most recently from dee525c to 8a5102a Compare October 14, 2026 03:00


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]>
@fcostaoliveira
fcostaoliveira force-pushed the test/redirect-and-txn-pin-gaps branch from 8a5102a to b1214ba Compare October 14, 2026 03:02
@fcostaoliveira
fcostaoliveira merged commit 4fb423f into master Oct 14, 2026
127 checks passed
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.

1 participant