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

[BUG] Kvrocks SCAN does not match with Redis SCAN #534

Closed
VictorCam opened this issue Apr 12, 2022 · 6 comments
Closed

[BUG] Kvrocks SCAN does not match with Redis SCAN #534

VictorCam opened this issue Apr 12, 2022 · 6 comments

Comments

@VictorCam
Copy link

Describe the bug
Scanning on Kvrocks produces incorrect responses when compared to Redis.

image
image

To Reproduce
Steps to reproduce the behavior:

  1. run docker
  2. get images "docker pull redis" and "docker pull kvrocks/kvrocks"
  3. "docker run --rm -d -p 6666:6666/tcp kvrocks/kvrocks:latest"
  4. "docker run --rm -d -p 6379:6379/tcp redis:latest"
  5. open two redis-cli instances one on port 6739 and 6666
  6. set "hi" and set "hello there" on both instances
  7. preform the same queries as shown in the image.

Expected behavior
I believe scan should be the same as how redis is preforming the scan.

@ShooterIT
Copy link
Member

@VictorCam Thanks for your report
there are two difference with redis, i find

@VictorCam
Copy link
Author

Thank you for the quick response and explanation. I'd be nice to have that implemented. I believe it can be useful in certain scenarios. Though feel free to decide if you'd like to implement it or not considering that fact that it will be inefficient.

@adulau
Copy link
Contributor

adulau commented Apr 29, 2022

and if you are curious, we maintain a fork of the Redis Python library to make the iterator works on kvrocks.

@tisonkun
Copy link
Member

@ShooterIT Another concern is that on Kvrocks, SCAN return the cursor "_hello" but actually if you want to iterate on next element, it requires a number based cursor.

For example:

127.0.0.1:6666> set "hi there" v0
OK
127.0.0.1:6666> set "hello" v1
OK
127.0.0.1:6666> SCAN 0 MATCH hel* COUNT 10000
1) "_hello"
2) 1) "hello"
127.0.0.1:6666> SCAN 0 MATCH he* COUNT 10000
1) "_hello"
2) 1) "hello"
127.0.0.1:6666> SCAN 0 MATCH h* COUNT 10000
1) "_hi there"
2) 1) "hello"
   2) "hi there"
127.0.0.1:6666> SCAN "_hi there" MATCH h* COUNT 10000
1) "0"
2) (empty array)
127.0.0.1:6666> SCAN "hi there" MATCH h* COUNT 10000
1) "0"
2) (empty array)
127.0.0.1:6666> SCAN 1 MATCH h* COUNT 10000
1) "_hi there"
2) 1) "hi there"

Note that SCAN "_hi there" ... returns "0".

@tisonkun
Copy link
Member

Sorry. I get it wrong.

127.0.0.1:6666> SCAN 1 MATCH h* COUNT 1
1) "_hi there"
2) 1) "hi there"
127.0.0.1:6666> SCAN 0 MATCH h* COUNT 1
1) "_hello"
2) 1) "hello"
127.0.0.1:6666> SCAN "_hello" MATCH h* COUNT 1
1) "_hi there"
2) 1) "hi there"

The cursor should work.

@PragmaTwice
Copy link
Member

See #1489.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants