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 crash in zset store getkeys, fix zdiff/bzmpop range, add tests #2051

Merged
merged 2 commits into from
Jan 25, 2024

Conversation

enjoy-binbin
Copy link
Member

These following cases will crash the server, the reason is that
the index of numkeys is wrong:

command getkeys zdiffstore dst 2 src1 src2
command getkeys zinterstore dst 2 src1 src2
command getkeys zunionstore dst 2 src1 src2

These following getkeys output is wrong:

> command getkeys zdiff 2 key1 key2
1) "key1"
2) "key2"
3) (nil)

> command getkeys bzmpop 0 2 key1 key2
1) "key1"

These are ok:

command getkeys zinter 2 key1 key2
command getkeys zunion 2 key1 key2
command getkeys sintercard 2 key1 key2
command getkeys zintercard 2 key1 key2
command getkeys zmpop 2 key1 key2
command getkeys lmpop 2 key1 key2
command getkeys blmpop 0 2 key1 key2

However, at present, there is still a problem with our zset store.
We do not support returning dst key, but let's do it later...

127.0.0.1:6379> command getkeys zinterstore dst 2 src1 src2
1) "dst"
2) "src1"
3) "src2"

127.0.0.1:6666> command getkeys zinterstore dst 2 src1 src2
1) "src1"
2) "src2"

These following cases will crash the server, the reason is that
the index of numkeys is wrong:
```
command getkeys zdiffstore dst 2 src1 src2
command getkeys zinterstore dst 2 src1 src2
command getkeys zunionstore dst 2 src1 src2
```

These following getkeys output is wrong:
```
> command getkeys zdiff 2 key1 key2
1) "key1"
2) "key2"
3) (nil)

> command getkeys bzmpop 0 2 key1 key2
1) "key1"
```

These are ok:
```
command getkeys zinter 2 key1 key2
command getkeys zunion 2 key1 key2
command getkeys sintercard 2 key1 key2
command getkeys zintercard 2 key1 key2
command getkeys zmpop 2 key1 key2
command getkeys lmpop 2 key1 key2
command getkeys blmpop 0 2 key1 key2
```

However, at present, there is still a problem with our zset store.
We do not support returning dst key, but let's do it later...
```
127.0.0.1:6379> command getkeys zinterstore dst 2 src1 src2
1) "dst"
2) "src1"
3) "src2"

127.0.0.1:6666> command getkeys zinterstore dst 2 src1 src2
1) "src1"
2) "src2"
```
Copy link
Member

@git-hulk git-hulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Copy link
Member

@jihuayu jihuayu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too, thanks.

@git-hulk git-hulk merged commit 044b6fd into apache:unstable Jan 25, 2024
30 checks passed
@jihuayu
Copy link
Member

jihuayu commented Jan 25, 2024

I think we need to inform developers that in versions of kvrocks before 2.8, some commands may cause server crashes.
Can we add this to the release log and supported-commands desc?

@enjoy-binbin enjoy-binbin deleted the fix_command_range branch January 25, 2024 11:31
@git-hulk
Copy link
Member

@jihuayu Thanks for your warm reminder. Yes we should mention this in our next release note.

enjoy-binbin added a commit to enjoy-binbin/kvrocks that referenced this pull request Jan 26, 2024
For store key related commands, we cannot extract the store
key, see apache#2051. This PR adds store_key to CommandKeyRange to
represent its index.

This PR handle these store key commands:
- zunionstore
- zinterstore
- zdiffstore
- georadius
- georadiusbymember
- geosearchstore

before:
```
> command getkeys zinterstore dst 2 src1 src2
1) "src1"
2) "src2"
> command getkeys GEORADIUS src 1 1 1 km store dst
1) "src"
> command getkeys GEORADIUSBYMEMBER src member radius m store dst
1) "src"
> command getkeys GEOSEARCHSTORE dst src frommember member byradius 10 m
1) "dst"
```

after:
```
> command getkeys zinterstore dst 2 src1 src2
1) "dst"
2) "src1"
3) "src2"
> command getkeys GEORADIUS src 1 1 1 km store dst
1) "src"
2) "dst"
> command getkeys GEORADIUSBYMEMBER src member radius m store dst
1) "src"
2) "dst"
> command getkeys GEOSEARCHSTORE dst src frommember member byradius 10 m
1) "dst"
2) "src"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants