Repository navigation
Conversation
Adds tests/pytest/test_rdb_dictionary_truncated.py (test plan section 3.7): - A stream RDB cut at record boundaries and inside records, including inside a definition and inside a record that refers to it: the server stops with a short read, the module refuses nothing and nothing crashes. - A stream RDB missing a later definition record, or a reset record: the load is refused with base_id_mismatch at the record after the gap. - A replica whose full sync from a mock master is cut inside a record, then between two records, retries and loads the whole stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## MOD-20882-rdb-dictionary-cluster #1704 +/- ##
====================================================================
+ Coverage 87.74% 87.83% +0.08%
====================================================================
Files 18 18
Lines 6723 6723
====================================================================
+ Hits 5899 5905 +6
+ Misses 824 818 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 523de41. Configure here.
Flex saves each value on its own (mode=local reason=flex), so it writes no stream for these tests to check. test_rdb_dictionary.py skips Flex the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LiranAbir
added a commit
that referenced
this pull request
Nov 19, 2026
…ation, damaged input, data shapes and defrag (#1699) * MOD-20882: test RDB encoding v5 on every shard of a 3-shard cluster test_rdb_dictionary.py checks one server and skips cluster mode, and the CI cluster lane runs one shard. The new file starts its own cluster of 3 shards, each with a replica, and checks that every shard writes and loads its own stream: - a SAVE on each master logs mode=stream and refers to its keys' shared strings, and the RDB is more than 4 times smaller than with sharing off; - a restart and DEBUG RELOAD of each shard load that stream and keep the data; - each replica full-syncs a stream from its master and holds the same data; - a promoted replica writes and reloads its own stream. The tests skip outside the oss-cluster lane, including existing-env. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: keep server logs on outside the short-read test test_short_read.py set Defaults.no_log = True when it was imported. RLTest imports every test file before a run, so every server in a full run logged to /dev/null, and every test that reads the server log skipped in CI: the three new cluster tests, and three tests of test_rdb_dictionary.py. testShortReadJson now builds its own Env with no_log set, and restores the default right after, so only its servers log nowhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: test RDB encoding v5 across a resharding with MIGRATE (#1700) `redis-cli --cluster reshard` moves a slot with MIGRATE, and the target RESTOREs every key without a load session, so each payload must be self-contained. A new test file starts its own 2-shard cluster and moves a slot of documents that share long strings with the target's own documents: one key alone, then COPY and REPLACE over KEYS, and again while the source runs a BGSAVE. The documents must arrive intact, the target must refuse no record, and both shards must still save and load a stream afterwards. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: test RDB encoding v5 on more full-sync paths (#1701) test_rdb_dictionary.py syncs a replica from a file and over the RDB channel into an empty replica. The new tests add the socket sync on the replication link itself, a replica asked for swapdb, a replica of a replica, and a replica that restarts on its own RDB and resumes with a partial sync. Each one checks that the sending side saved a stream, the receiving side loaded it with no refused record, and every document arrived. swapdb never runs with RedisJSON loaded: the module doesn't declare that it handles async loading, so the replica loads from a file. The test pins that. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: test RDB encoding v5 around atomic slot migration (#1702) A new test_rdb_dictionary_asm.py starts its own 2-shard cluster and holds a slot export open after its snapshot fork, so saves can run during it: - A BGSAVE on the exporting node logs mode=local reason=asm, while one on the importing node keeps streaming. Writes to shared-string keys during the snapshot reach the destination intact, nothing is refused, and the source trims the keys it gave away. Afterwards both nodes save and reload a stream again. - After a cancelled export and after one that fails at its handoff, the source streams again. Stacks on #1699. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: test RDB encoding v5 with unusual data shapes (#1703) * MOD-20882: test RDB encoding v5 with unusual data shapes A new tests/pytest/test_rdb_dictionary_shapes.py, test-only, plain lane only. Each test saves a stream, checks the counters the module logged for it, and reloads every document exactly: - strings under 8 UTF-8 bytes (and empty ones) are never shared, while 8-byte, emoji and CJK strings are; - a document larger than a 1% table fills it mid-document: the rest stays inline, and the next document starts with a reset; - a 2 MB string is written once for three documents, next to FP32 typed arrays that keep their type through the reload; - COPY, JSON.MERGE and a value equal to an object key add owners; - STRAPPEND, JSON.DEL, JSON.SET and DEL between saves still round-trip; - a shared string at JSON.SET's nesting limit round-trips. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: skip the stream checks on Flex Flex saves each value on its own (mode=local reason=flex), so it writes no stream for these tests to check. test_rdb_dictionary.py skips Flex the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: test truncated and partial RDB encoding v5 input (#1704) * MOD-20882: test truncated and partial RDB encoding v5 input Adds tests/pytest/test_rdb_dictionary_truncated.py (test plan section 3.7): - A stream RDB cut at record boundaries and inside records, including inside a definition and inside a record that refers to it: the server stops with a short read, the module refuses nothing and nothing crashes. - A stream RDB missing a later definition record, or a reset record: the load is refused with base_id_mismatch at the record after the gap. - A replica whose full sync from a mock master is cut inside a record, then between two records, retries and loads the whole stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: skip the stream checks on Flex Flex saves each value on its own (mode=local reason=flex), so it writes no stream for these tests to check. test_rdb_dictionary.py skips Flex the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: test RDB encoding v5 with active defrag and the AOF preamble in the plain lane (#1706) * MOD-20882: test RDB encoding v5 with active defrag and in the plain-lane AOF path Redis defragments while it loads only during an AOF load, where a stream load holds the strings it interned. A defrag cycle that starts while the AOF tail replays must leave the string cache to the load: the save after it must define each shared string once. A defrag cycle between two saves moves every string, and the second save must still share them. The AOF preamble test runs in the plain lane, the only lane that the sanitizer job runs. test_rdb_dictionary.py checks the preamble only in the --use-aof lane. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: skip the stream checks on Flex and start from an empty database Flex saves each value on its own (mode=local reason=flex), so it writes no stream for these tests to check. test_rdb_dictionary.py skips Flex the same way. The checks count every key the server holds, so the test env helper now runs FLUSHALL first, in case a run reuses a server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * MOD-20882: check the exact key set after reloads and MIGRATE The cluster and MIGRATE tests checked only the keys that SCAN found after a restart, a DEBUG RELOAD, a promotion or a slot move, so a load or a MIGRATE that lost keys still passed while more than one key was left (Cursor Bugbot). Each check now compares the keys a server holds with the keys it should hold: - test_rdb_dictionary_cluster.py: the keys each shard held once the documents were written. The full-sync check also catches extra keys on the replica now. - test_rdb_dictionary_migrate.py: after the reshard, the target holds its own keys plus every moved key, and the source holds none of the moved keys. A DEBUG RELOAD keeps the keys the server held before it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Why
Stacks on #1699 (base
MOD-20882-rdb-dictionary-cluster). This is §3.7 (truncated and partial input) of the MOD-20882 OSS test plan.test_rdb_dictionary.pyalready refuses a stream that lost its first definition, has an unknown marker, or has a reset record that defines nothing.test_short_read.pycuts only an RDB that RedisJSON 2.0.0 wrote. Nothing checked a v5 stream RDB that ends early, a stream missing a record from its middle, or a replica whose full sync of a stream is cut while it loads from the socket. The module's short-read handling was unit-tested only.What
A new
tests/pytest/test_rdb_dictionary_truncated.py, test-only. Each test builds its ownEnv, sets noDefaults, and imports onlycommonand RLTest.test_a_stream_rdb_cut_short_stops_the_load_without_a_crash(plain and--use-slaves): a 40-key stream RDB is cut at 9 points: at record boundaries, inside a key name, inside the first record's base id, inside the record that defines the shared strings, inside a record that refers to them, and before a value's end mark. A server started on each cut file stops with Redis'sShort read or OOM loading DB. It does not crash, and the module logs no refusal, since a cut value is a short read, not a refused record. The whole file is the control: it loads every document.test_a_stream_rdb_missing_a_record_from_its_middle_is_refused(plain and--use-slaves): removing a later record that defines a string, or a whole reset record, makes the load refuse the next record withreason=base_id_mismatch expected=<n> found=<m>. Base ids count definitions across resets, so a dropped reset is caught too.test_a_full_sync_cut_while_the_replica_loads_is_retried_and_loads_the_whole_stream(plain): the server becomes the replica of a small mock master that sends the stream RDB withrepl-diskless-load on-empty-db. The first transfer ends inside a record that refers to the shared strings, and the second ends between two records. Each fails withFailure loading rdb format from socketand the replica keeps running. The third transfer is whole, logsphase=loading_endedwith every reference, refuses nothing, and leaves all 400 documents intact. A mock master is used because a real master can't choose where the cut lands.The test plan suggested adding this to
test_short_read.py. A new file keeps it apart from that file's gevent shard mock and its own RDB.Testing
Run locally (macOS arm64) against Redis
unstable456b4b9a, with RedisJSON built from this branch, andtest_short_readloaded in the same run as in CI:--use-slaves--use-aofcrashedon the 3 cuts inside a record); mock-master test errors (the server crashes on the cut inside a record)base_id_mismatch expected=2 found=0and the server terminatesThe replica log shows each transfer behaving as designed. The cut inside a record releases the load session with no line. The cut between records logs
phase=loading_failed ... stream_docs=200. The whole transfer logsphase=loading_ended ... refs=798 stream_docs=400.🤖 Generated with Claude Code
Note
Low Risk
Test-only change with no production code; expands pytest coverage for RDB load and replication edge cases.
Overview
Adds
tests/pytest/test_rdb_dictionary_truncated.py(MOD-20882 §3.7): integration coverage for damaged v5 stream RDBs that existingtest_rdb_dictionary.py/test_short_read.pydo not hit.Truncated files: builds uncompressed stream RDBs, cuts them at nine byte offsets, and boots a fresh Redis+module instance on each cut. Expects clean exit with Redis
Short read or OOM loading DB, no crash, and no modulestatus=refused.Missing middle record: splices out a later definition or a reset record and expects load refusal with
base_id_mismatch.Interrupted replica sync: uses a mock master with
repl-diskless-load on-empty-dbto send two partial RDB transfers then a full one; asserts socket load failures, retry, successfulphase=loading_ended, and all documents present.Includes RDB parsing helpers, subprocess server harness, and environment skips (cluster, AOF, flex/BigRedis, etc.).
Reviewed by Cursor Bugbot for commit 8cc14b3. Bugbot is set up for automated code reviews on this repo. Configure here.