Skip to content
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

Fix zset can't add the same member with different scores #298

Merged
merged 2 commits into from
Jun 7, 2021
Merged

Fix zset can't add the same member with different scores #298

merged 2 commits into from
Jun 7, 2021

Conversation

git-hulk
Copy link
Member

@git-hulk git-hulk commented Jun 5, 2021

Fix the corner case that adds the same member which may add the score
column family many times and cause problems in the ZRANGE command.

For example, we add members with ZADD mykey 1 a 2 a and ZRANGE mykey 0 1
return only one member(a) was expected but got the member a twice now.

The root cause of this issue was the score key was composed by member and score,
so the last one can't overwrite the previous when the score was different.
A simple workaround was add those members with reversed order and skip the member if has added.

@git-hulk
Copy link
Member Author

git-hulk commented Jun 5, 2021

Many thanks for @smartlee finding this issue

Fix the corner case that adds the same member which may add the score
column family many times and cause problems in the ZRANGE command.

For example, we add members with `ZADD mykey 1 a 2 a` and `ZRANGE mykey 0 1`
return only one member(`a`) was expected but got the member `a` twice now.

The root cause of this issue was the score key  was composed by member and score,
so the last one can't overwrite the previous when the score was different.
A simple workaround was add those members with reversed order and skip the member if has added.
ShooterIT
ShooterIT previously approved these changes Jun 7, 2021
karelrooted
karelrooted previously approved these changes Jun 7, 2021
@git-hulk git-hulk dismissed stale reviews from karelrooted and ShooterIT via b974eb8 June 7, 2021 10:33
@git-hulk git-hulk merged commit 9129098 into apache:unstable Jun 7, 2021
@ShooterIT ShooterIT changed the title Fix zset add the same member with different scores Fix zset can't add the same member with different scores Jul 15, 2021
ShooterIT pushed a commit to ShooterIT/kvrocks that referenced this pull request Jul 15, 2021
Fix the corner case that adds the same member which may add the score
column family many times and cause problems in the ZRANGE command.

For example, we add members with `ZADD mykey 1 a 2 a` and `ZRANGE mykey 0 1`
return only one member(`a`) was expected but got the member `a` twice now.

The root cause of this issue was the score key was composed by member and score,
so the last one can't overwrite the previous one when the score was different.
A simple workaround was to add those members with reversed orders and skip the member if has added.
@ShooterIT ShooterIT mentioned this pull request Jul 15, 2021
ShooterIT pushed a commit that referenced this pull request Jul 19, 2021
Fix the corner case that adds the same member which may add the score
column family many times and cause problems in the ZRANGE command.

For example, we add members with `ZADD mykey 1 a 2 a` and `ZRANGE mykey 0 1`
return only one member(`a`) was expected but got the member `a` twice now.

The root cause of this issue was the score key was composed by member and score,
so the last one can't overwrite the previous one when the score was different.
A simple workaround was to add those members with reversed orders and skip the member if has added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants