Repository navigation
Test the -READONLY retry to the slot primary under RESP2 and RESP3 - #886
Merged
Merged
Conversation
The read-preference failover cells ran test_readonly_retry_resp2_resp3, a placeholder that always skipped: it waited for a way to time CLUSTER FAILOVER against an in-flight pipeline (its TODO named #100, an unrelated PR). The drop tests (#592, #651) cover a -READONLY that is not retried, but nothing covered the resend itself. test_cluster_readonly_retry.py drives it with two scripted peers on ephemeral ports, so it needs no replicas or failover timing, under --protocol=resp2 and resp3: - stale primary: the map names A the primary. B answers its first SET with -CLUSTERDOWN, memtier refreshes through B and the new map makes B the primary and A its replica. A holds its SETs until memtier sends it READONLY, which it does only once the new map is applied, then rejects them with -READONLY. They must be resent to B. - replica read: a SET marked --command-is-read goes to replica A under --read-preference=secondary and is rejected; it must be resent to the primary B. Each key must be accepted by B exactly once after at most one rejection by A. The JSON must count each request once, with no errors, Retry Attempts and Retried Ops matching the resends, a histogram of the run's requests and, for the replica read, latency spanning both attempts. No key is written to --failed-keys-file, and the --requests run must exit 0. Reverting the resend, resending to the rejecting connection, routing the resend by --read-preference, double counting, or skipping the retry counters fails the tests. The placeholder is removed. The new file runs in every default cell. Fixes #462 Co-Authored-By: Claude Opus 5.5 <[email protected]>
#462 was narrowed to one remaining gap: get_cluster_replica_connections() returned an empty list when CLUSTER NODES listed no replicas, or when reading it raised, and its 22 callers in the read-preference, key-affix and failover tests then called env.skip(). RLTest counts a skip as a pass, so an OSS-CLUSTER + replicas cell that lost its replicas went green. The docstring and README still blamed RLTest's --slaveof replicas, which the pinned fork replaced with CLUSTER MEET and CLUSTER REPLICATE. On a cluster started with --use-slaves (OSS_CLUSTER_REPLICAS=1), the helper now raises AssertionError in both cases, with the CLUSTER NODES reply or the error, so those tests fail. Cells without replicas still get an empty list and skip. test_requests_complete_after_primary_failover finds its replica on its own and fails the same way. The docstrings and the README section describe the current behaviour. test_cluster_readonly_retry.py: C, the seed, and D, last in the map, each own a slot no key maps to and must get no SET, so a resend to the lowest- or highest-numbered other connection instead of the slot primary fails all 4 tests (it passed them before). The stale-mode comment now says A's SETs are rejected after READONLY: held until it, or sent after it. Fixes #462 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
Owner summary at 92d6a7e: all 7 lenses approve (SEM, OUT, TEST, BUILD, LIFE, INTER, MAINT).
🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #462.
Problem
The pinned RLTest fork already fixed #462's root cause:
--use-slavesreplicas now join the cluster, and on master the read-preference cells run 29 tests that pass. The one skip left wastest_readonly_retry_resp2_resp3, a placeholder that always skipped. Its TODO named #100, an unrelated PR. The drop tests (#592, #651) cover a-READONLYthat isn't retried, but nothing covered the resend itself.Change
New
tests/test_cluster_readonly_retry.py, with four scripted peers on ephemeral ports (two decoys). It needs no replicas and no failover timing, and runs under--protocol=resp2andresp3:-CLUSTERDOWN, so memtier refreshes through B, and the new map makes B the primary and A its replica. A holds its SETs until memtier sends itREADONLY, which memtier does only after applying the new map. A then rejects them, and any sent after it, with-READONLY, and they must be resent to B.--command-is-readgoes to replica A under--read-preference=secondary. A rejects it, and it must be resent to the primary, B.Each test checks:
Retry AttemptsandRetried Opsmatch the resends;--failed-keys-filestays empty;--requestsrun ends with exit code 0.The placeholder is removed.
The rest of #462: when replicas are expected but discovery finds none, the read-preference tests skipped instead of failing, and the cell still went green.
--use-slaves(OSS_CLUSTER_REPLICAS=1) in cluster mode,get_cluster_replica_connections()now raises when CLUSTER NODES lists no replicas or reading it fails. The message includes the reply or the error. It raises rather than asserting, because RLTest drops a failed assert when the test then skips.Tests
Discovery, both directions (3-shard cluster with replicas): with this PR 36 tests pass and none skip. When discovery finds no replicas, the 22 tests that the old tree skips (green) now fail. When discovery raises, 24 fail; 2 of those are slot-move tests the simulation breaks on the old tree too. Without replicas configured, the same 22 still skip.
Where it runs: the file runs in the 7 test-ubuntu cells, coverage shard 7/8, and the ASan, UBSan and TSan plaintext shard 1/2 cells (standalone and cluster).
Runs: 5/5. Under load (1 CPU, 2 busy loops, nice 19) it also passes 5/5.
Mutants: these fail all four tests: no retry, a retry to the same connection, double counting, either retry counter left unincremented, and a lost request. A resend routed by
--read-preferencefails the two replica-read tests. Removing the stale-primary guard is caught by the existingtest_cluster_readonly_drop.py.make check: 18/18.
Affected versions
Test-only. The placeholder came in with ee757e7 (#456,
--read-preference), so the gap is in 2.5.0 through 2.5.2 and master.🤖 Generated with Claude Code
Note
Low Risk
Test and documentation changes only; no production memtier_benchmark code paths are modified.
Overview
Adds deterministic integration tests for cluster
-READONLYhandling with--retry-on-error: a newtest_cluster_readonly_retry.pydrives memtier against four scripted TCP “shard” peers (no RLTest replicas or failover timing). It covers a stale topology path (-CLUSTERDOWN→ map refresh → replica rejects with-READONLY) and a replica read path (--read-preference=secondaryon a read-marked SET), under RESP2 and RESP3, asserting each key lands once on the slot primary, retry JSON counters, and exit 0. The always-skippingtest_readonly_retry_resp2_resp3placeholder intest_read_preference_failover.pyis removed.Tightens replica CI expectations (#462):
cluster_replicas_expected()plusget_cluster_replica_connections()now raise when the env was started with--use-slavesbutCLUSTER NODESis unreadable or lists no replicas, instead of warning and letting tests skip as green. Failover retry tests use the same rule when replica topology is missing. README replaces the old “testing limitations” harness-gap text with documentation of the pinned RLTest fork that registers replicas in the cluster.Reviewed by Cursor Bugbot for commit 92d6a7e. Bugbot is set up for automated code reviews on this repo. Configure here.