-
Notifications
You must be signed in to change notification settings - Fork 874
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
SRANDMEMBER
and SPOP
always returns/removes only the lowest scoring element(s)
#3018
Labels
bug
Something isn't working
Comments
BagritsevichStepan
pushed a commit
to BagritsevichStepan/dragonfly
that referenced
this issue
May 7, 2024
fixes dragonflydb#3018 Signed-off-by: Stepan Bagritsevich <[email protected]>
BagritsevichStepan
pushed a commit
to BagritsevichStepan/dragonfly
that referenced
this issue
May 8, 2024
fixes dragonflydb#3018 Signed-off-by: Stepan Bagritsevich <[email protected]>
BagritsevichStepan
pushed a commit
to BagritsevichStepan/dragonfly
that referenced
this issue
May 8, 2024
fixes dragonflydb#3018 Signed-off-by: Stepan Bagritsevich <[email protected]>
BagritsevichStepan
pushed a commit
to BagritsevichStepan/dragonfly
that referenced
this issue
May 9, 2024
fixes dragonflydb#3018 Signed-off-by: Stepan Bagritsevich <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
SRANDMEMBER
should return random elements from the specified set, instead, it only returns the lowest scoring element(s).The
SPOP
command has the same problem, each time it removes only the lowest scoring element(s) from the set.To Reproduce
SRANDMEMBER
The steps to reproduce the behavior of the
SRANDMEMBER
command:redis-cli SADD myset one two three four five six seven eight nine ten
seq 20 | xargs -I {} redis-cli SRANDMEMBER myset
The result is always "eight".
SPOP
The steps to reproduce the
SPOP
behavior are more tricky. After each deletion of an element, we must return it back to the set in order to keep the same set of elements:Insert elements into a set:
redis-cli SADD myset one two three four five six seven eight nine ten
Remove the element and return it back multiple times:
for i in {1..20}; do redis-cli SPOP myset | tee -a removed_members.txt | xargs -I {} redis-cli SADD myset {}; done
SPOP
andSADD
, we write theSPOP
result to the fileremoved_members.txt
. As a result, inremoved_members.txt
we can see which elements were deleted during theSPOP
commands.In
removed_members.txt
we can see that "eight" was deleted each time.Expected behavior
It is expected that both commands return/remove a pseudo random element for each invocation.
SRANDMEMBER
SPOP
Environment (please complete the following information):
Reproducible Code Snippet
SRANDMEMBER
redis-cli SADD myset one two three four five six seven eight nine ten seq 20 | xargs -I {} redis-cli SRANDMEMBER myset
SPOP
Additional context
The problem is very similar to #2850.
The text was updated successfully, but these errors were encountered: