fix(stream): bound range reads by metadata entries - #3595
Draft
wengsht wants to merge 1 commit into
Draft
Conversation
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.
Problem
Stream metadata defines the logical first and last live entry IDs, but the shared range path scans the raw RocksDB entry-key interval supplied by the caller.
If raw keys outside the metadata bounds remain after an interrupted or older slot migration, they become visible again through
XRANGE,XREVRANGE, and new-messageXREADGROUPreads. This makesXLEN/XINFO STREAMdisagree withXRANGEand can pin retention: a sweeper repeatedly starts from a stale pre-frontier entry whileXTRIMcorrectly treats the newer metadata frontier as authoritative.The completed #3592 prevents new trim
DeleteRangerecords from being lost during incremental slot migration, but existing divergent streams still need a read-side invariant.Change
Clamp the shared stream range interval to metadata's
[first_entry_id, last_entry_id]bounds:This is read-only hardening. It does not add cleanup writes to read commands or change stream metadata.
Test
The regression trims a stream, reinserts raw entry keys below and above its metadata bounds, and verifies:
Validation:
./x.py format./x.py check format./x.py build build-make --unittest -j 8RedisStreamTest.*cases passAI assistance was used for diagnosis and drafting; I reviewed the code and tests.