New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZRANDMEMBER only ever returns first n elements in sorted set #2850
Comments
Thanks for reporting this. Out of curiosity how do you use this command? I am asking because I have not seen much traction with RAND commands of Redis API. |
Sure thing! Thanks for the quick response. In this case, I am keeping global set of unique identifiers and the timestamp they were last updated in a handful of other data structures that all tie back to that identifier to track when they can be safely expired. The rand usage is probably somewhat niche - I use it to facilitate a couple of kinds of load testing of the datastore and the soft real-time API that sits in front of it. One such scenario is generating a constant read load in a production setting alongside normal traffic. The randomness is useful for generating synthetic read load that is dynamic to data that is known to be in the system at any given time. There are, of course, a thousand other ways to skin that cat, but I've found that this one to be one of the simplest and effective for the use cases (real-time, high data volume) I tend to have. |
I would like to add that SRANDMEMBERThe steps to reproduce the behavior of the
The result is always "eight". SPOPThe steps to reproduce the
In Expected behaviorRedis always removes a pseudo-random element. So, the result may differ between runs: $ cat removed_members.txt
ten
nine
four
five
eight
eight
one
nine
two
nine
three
five
four
nine
eight
five
four
two
six
two
two
ten
eight
two
five
ten
two
four
six
nine |
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes dragonflydb#2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
fixes #2850 Signed-off-by: Stepan Bagritsevich <[email protected]>
Describe the bug
ZRANDMEMBER
should return random elements from the specified sorted set, instead, it only returns the lowest scoring element(s).To Reproduce
Steps to reproduce the behavior:
redis-cli zadd x 2 b 1 a 4 d 3 c
seq 25 | xargs -I {} redis-cli ZRANDMEMBER x 1
Expected behavior
I expect to get a pseudo random element for each invocation of
ZRANDMEMBER
.The same steps above produce the expected randomized response when run against a standard redis docker image:
Environment (please complete the following information):
Reproducible Code Snippet
Additional context
The dragonfly website says it is fully compatible with Redis' implementation of
ZRANDMEMBER
, so it appears to be a bug instead of an intentional partial implementation.The text was updated successfully, but these errors were encountered: