Repository navigation
Conversation
redis/redis#16135 (8.12-rc3) adds ZMOVE, BZMOVE and ZMOVEMEMBER: - SortedSetMove (ZMOVE MIN|MAX [COUNT]) - from the low or high end - SortedSetMoveByScore (ZMOVE BYSCORE min max [COUNT]) - a score range - SortedSetMoveMembers (ZMOVEMEMBER [NX|XX] MEMBERS n ...) - named members, with When as the per-member condition on the destination Each returns SortedSetEntry[]?, null when nothing moved (the server's null reply is never folded into an empty array). COUNT is sent if and only if the caller gives one: for BYSCORE, no COUNT means the whole range, so the SortedSetPop habit of eliding COUNT 1 is not copied. The reply is nested [member, score] pairs in RESP2 as well as RESP3, unlike ZPOPMIN, so SortedSetWithScores does not fit; NullableSortedSetEntryArray is a strict nested-pair processor. BZMOVE is not exposed (blocking; policy row in CommandCoverage.md). Gated [Experimental] behind SER011 and the new RedisFeatures.v8_12_0_rc3 (8.11.242: rc2 does not have the commands); the test docker image moves to client-libs-test:8.12-rc3.
This branch has not been deployed
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.
Sub-PR of #3343.
IDatabasesupport for the sorted-set moves that Redis 8.12-rc3 adds (redis/redis#16135):ZMOVEandZMOVEMEMBER. Written against the client HLD inredis-developer/client-designs(redis-oss/client-hld/zmove/README.md).BZMOVEis not exposed, per the blocking-command policy.Surface
SortedSetMove(src, dst, Order order = Ascending, long? count = null)ZMOVE src dst MIN|MAX [COUNT n]SortedSetMoveByScore(src, dst, double start, double stop, Exclude exclude = None, long? count = null)ZMOVE src dst BYSCORE min max [COUNT n]SortedSetRemoveRangeByScoretakes themSortedSetMoveMembers(src, dst, RedisValue[] members, When when = Always)ZMOVEMEMBER src dst [NX|XX] MEMBERS n m...Whenis the per-member condition on the destinationAll return
SortedSetEntry[]?(andTask<...>twins), and all are[Experimental(Experiments.Server_8_12)].Choices worth a look:
nullmeans nothing moved. The server's null reply is never folded into an empty array; same contract as theLMOVEMoverload ofListMove.COUNTpasses through. It is sent if and only if the caller gives one, including 1 and values the server rejects.SortedSetPopelidesCOUNT 1; that is not copied, because forBYSCOREno count means the whole range.SortedSetMove(a, b, 0, 5)would be ambiguous betweenOrder/long?anddouble/double(literal 0 converts to an enum).start/stopare required onSortedSetMoveByScore: infinite defaults would make a bare call move the whole set.NXorMEMBERSis data, and an empty list goes out asMEMBERS 0for the server to reject.Reply parsing
The reply is nested
[member, score]pairs in RESP2 as well as RESP3 (only the score type differs), unlikeZPOPMIN.SortedSetWithScoresreads RESP2 as a flat interleaved list, so there is a new strict processor,ResultProcessor.NullableSortedSetEntryArray; a flat list or a non-pair is an unexpected reply rather than a guess.Routing, retry, coverage
CommandRetryWriteAccumulating, alongsideZMPOP.BZMOVEgets apolicyrow indocs/CommandCoverage.md; no enum member, as withBZMPOP.SMOVErow.SortedSetRemove+SortedSetAddwrites the caller's score and adds unconditionally;ZMOVEMEMBERcarries the source's score and moves nothing when the source lacks the member.Shared 8.12 plumbing
RedisFeatures.v8_12_0_rc3(8.11.242) andRedisFeatures.SortedSetMove: the existingv8_12_0is rc2 (8.11.241), which does not have these commands.client-libs-test:8.12-rc3(Dockerfile and compose). rc3 requirescluster-bus-port-protected-mode nofor a plaintext cluster bus; the cluster configs on this branch already set it.docs/exp/SER011.mdgains the feature bullet.Tests
ResultProcessorUnitTests/SortedSetMove: RESP2 and RESP3 pairs, single pair stays nested, infinite scores, order, both null forms, empty array, six malformed shapes.RoundTripUnitTests/SortedSetMoveRoundTrip: exact bytes for every token shape, plus argument validation.SortedSetMoveTests(live,[RunPerProtocol],require: v8_12_0_rc3): selection, count, null cases, same key, conditions, keyword-like members, server errors, transaction, key prefix, and two cluster tests (same-slot routing; cross-slot refused with nothing moved).KeyPrefixed*forwarding tests for all six members.Run locally: 76/76 on net10.0 and net8.0 against throwaway 8.12-rc3 standalone and single-node cluster servers. Full suite on net10.0 against an older (8.9.241) topology: 6838 pass, 254 skip, 1 fail (
FailoverTests.SubscriptionsSurvivePrimarySwitchAsync, which passed on one of two isolated reruns; not checked on the base branch). net481 not run.dotnet build Build.csproj -c Release /p:CI=trueis clean apart from the NU1903 ILCompiler advisory intoys/AotRig.Known, not addressed here
On a cluster, cross-slot keys are refused by the library for the bare
SortedSetMove(src, dst)and by the server (CROSSSLOT) for the other forms. The cause is inMessage.cs: the two-key messages carrying two or more values do not combine the second key into the hash slot. It predates this branch and same-slot calls route correctly; the cluster test accepts either layer. To be handled separately.