Repository navigation
MOD-18948: verify every write command replicates to the replica - #1656
Merged
Merged
Conversation
A write command can be implemented correctly on the primary while its propagation to the replica is wrong or missing, and nothing in the suite catches it. The divergence is silent -- master_link_status:up, matching replication offsets -- until a failover promotes the replica. MOD-16050 is the canonical case: in RedisBloom, CF.LOADCHUNK replicated only its header chunk and never the data chunks, and CF.INFO reported the full inserted count on both sides while the replica held nothing. The suite already runs once with --use-slaves, but that variant only asserts the primary's replies. Nothing ever reads the replica. Add tests/pytest/test_replication.py, a table of one representative invocation per write command (15 of them). Each row runs on the primary, waits for the replica to ack, then compares the key set and the document read back in full. The invocation per command is chosen to be the form most likely to diverge rather than the simplest one: a mid-array index over a tail append, a null-valued JSON.MERGE (which deletes the member) over a plain overwrite, a float delta on an integer (which promotes the stored type), create-on-write over overwriting an existing key. No argument permutations. JSON.GET '$' is the fingerprint rather than DUMP: unlike a probabilistic sketch, a JSON document has no internal state the full read does not show, and this suite sets Defaults.decode_responses, so a binary RDB payload cannot come back over these connections. A read that returns the type default proves nothing, since both sides match trivially. Every row asserts the primary's read-back is non-default before comparing it, and asserts WAIT actually acked rather than timing out. testEveryWriteCommandIsCovered enumerates write commands from the running server via COMMAND LIST FILTERBY MODULE and fails if any is missing from the table, so a newly added command cannot land without a replication test. Co-Authored-By: Claude Opus 5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1656 +/- ##
=======================================
Coverage 88.06% 88.06%
=======================================
Files 17 17
Lines 5957 5957
=======================================
Hits 5246 5246
Misses 711 711 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AvivDavid23
approved these changes
Sep 30, 2026
LiranAbir
added a commit
that referenced
this pull request
Oct 8, 2026
…1662) Two of the three nightly failures since #1656 are the same hang, in the --use-aof env group, after test_replication had already passed: 09-30 x64-bionic and 10-01 x64-rocky10: test_replication:testEveryWriteCommandIsCovered [PASS] Test Timeout, printing trace. redis_std.py stopEnv -> _stopProcess(SLAVE) -> process.communicate() RLTest sends SIGTERM to the test's replica, waits 30 s, then calls communicate() with no timeout; the replica, running with AOF, did not exit. The hang predates this test -- test_mset_replication_in_aof hits it too, with a replica running AOF -- but in the --use-aof group no other test starts a replica, so test_replication is what brings one in. Raising the WAIT timeout would not help: the test itself passes. - testWriteCommandsReplicate skips under AOF, before it builds the replica env. Replication stays covered by the general and --use-slaves groups. - testEveryWriteCommandIsCovered no longer asks for a replica at all: it only reads the command table, and it is the test whose teardown hung on both legs. Locally, every tests.sh variant passes, and under --use-aof no replica is started any more. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
MOD-18948 — RedisJSON half. RedisBloom half is RedisBloom/RedisBloom#1072.
Why
A write command can be implemented correctly on the primary while its propagation to the replica is wrong or missing, and nothing in the suite catches it. The divergence is silent —
master_link_status:up, matching replication offsets — until a failover promotes the replica. MOD-16050 is the canonical case: in RedisBloom,CF.LOADCHUNKreplicated only its header chunk and never the data chunks, whileCF.INFOreported the full inserted count on both sides and the replica held nothing.The suite already runs once with
--use-slaves, but that variant only asserts the primary's replies. Nothing ever reads the replica.What
tests/pytest/test_replication.py— a table of one representative invocation per write command (15). Each row runs on the primary, waits for the replica to ack, then compares the key set and the document read back in full.The invocation per command is chosen to be the form most likely to diverge rather than the simplest one:
JSON.ARRINSERT $.arr 1,JSON.ARRPOP $.arr 1,JSON.DEL $.arr[1]) — the elements after it shift,JSON.MERGE(RFC 7386: deletes the member) over a plain overwrite,JSON.NUMINCRBY $.a 1.5) — promotes the stored number's type,No argument permutations, no encoding matrix.
testEveryWriteCommandIsCoveredenumerates write commands from the running server (COMMAND LIST FILTERBY MODULE ReJSON, filtered on thewriteflag) and fails if any is missing from the table — a newly added command cannot land without a replication test. It currently discovers exactly the 15 in the table.Runs on a standalone
Env(useSlaves=True), ~13s. Picked up by the default RLTest collection, so notests.shchange.Notes
JSON.GET '$'is the fingerprint rather thanDUMP. Unlike a probabilistic sketch, a JSON document has no internal state the full read does not show — and this suite setsDefaults.decode_responses, so a binary RDB payload cannot come back over these connections. (The RedisBloom PR does compareDUMP, because there a bloom bit array is invisible to every read command.)WAITactually acked rather than timing out.RLTeststarts the replica with--slaveofbut never waits for the sync, so the test pollsmaster_link_statusbefore the first write.--env oss-cluster: RLTest's cluster env creates no replicas at all, and itsgetSlaveConnection()is an unconditionalraise.Verification
All four
tests.shvariants, locally:--use-slaves--use-aof--env oss-clusterNegative controls, run and then discarded:
RedisTimeSeries is the remaining module; the enterprise side is RED-217947.
🤖 Generated with Claude Code
Note
Low Risk
Test-only change; no production or replication implementation code is modified.
Overview
Adds
tests/pytest/test_replication.pyso each ReJSON write command gets a primary→replica integrity check—addressing gaps where replication can look healthy but data diverges (MOD-18948).testWriteCommandsReplicateruns 15 table-driven cases on a standaloneEnv(useSlaves=True, protocol=2): flush, optional setup, one “stress” write per command,WAITfor replica ack, then compare key sets andJSON.GET/JSON.TYPEon master vs replica. Helpers wait formaster_link_status: up, reject trivial readbacks, and surface replica read errors without aborting other rows. Skipped on cluster (no replica connection).testEveryWriteCommandIsCovered(Redis ≥7) lists module write commands viaCOMMAND LIST/COMMAND INFOand fails if any are missing from the table (withKNOWN_EXCLUSIONSfor intentional gaps).Reviewed by Cursor Bugbot for commit da6b722. Bugbot is set up for automated code reviews on this repo. Configure here.