Repository navigation
fix(rueidiscompat): send TS.MREVRANGE from TSMRevRange - #1053
Merged
Merged
Conversation
TSMRevRange built TsMrange(), so it sent TS.MRANGE and returned samples in ascending order. TSMRevRangeWithArgs and go-redis send TS.MREVRANGE and return them in descending order. Check the sample order in the adapter test, and correct the pipeline golden that recorded TS.MRANGE for TSMRevRange.
rueian
approved these changes
Nov 10, 2026
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.
TL;DR
Compat.TSMRevRangesentTS.MRANGE, so it returned samples oldest first. It now sendsTS.MREVRANGE, which matchesTSMRevRangeWithArgsand go-redis. No API change.Problem
TSMRevRangebuiltTsMrange()instead ofTsMrevrange()(adapter.go:4952). There is no error, so code that treats the first sample as the latest one silently reads the oldest one.One series with samples at 1000, 2000, 3000, then
TSMRevRange(ctx, 0, 10000, filter):It has been this way since
TSMRevRangewas added in #422. The tests didn't catch it:TS.MRANGEforTSMRevRange, so it pinned the bug.The other range commands (
TSRange,TSRevRange,TSMRange, and theirWithArgsvariants) use the right builders.Fix
adapter.go: useTsMrevrange()inTSMRevRange.adapter_test.go: also check the first and last samples, so the test fails if the order is wrong.pipeline_test.go: change the golden entry forTSMRevRangefromTS.MRANGEtoTS.MREVRANGE.Verification
Tested on main @ e03a107 with Redis 7.4.0 (redis-stack) and Redis 8.2.11:
adapter.gochange, both the new assertion andTestPipelinerfail.TestPipelinerpass.Note
Medium Risk
Fixes silent wrong sample ordering for any caller relying on TSMRevRange for “latest first” data; behavior change is intentional and aligns with the command name and other clients.
Overview
Compat.TSMRevRangewas issuingTS.MRANGE, so multi-series reverse-range results came back oldest-first instead of newest-first—unlikeTSMRevRangeWithArgsand go-redis. The builder is nowTsMrevrange()so the client sendsTS.MREVRANGE; the public API is unchanged.Tests were tightened so regressions on order are caught: adapter specs assert the first and last samples in each series, and the pipeline golden for
TSMRevRangeexpectsTS.MREVRANGEinstead ofTS.MRANGE.Reviewed by Cursor Bugbot for commit b97e484. Bugbot is set up for automated code reviews on this repo. Configure here.