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

Inconsistent behavior with Redis in BITFIELD GET command #2500

Open
1 of 2 tasks
VIVALXH opened this issue Aug 21, 2024 · 2 comments
Open
1 of 2 tasks

Inconsistent behavior with Redis in BITFIELD GET command #2500

VIVALXH opened this issue Aug 21, 2024 · 2 comments
Labels
bug type bug

Comments

@VIVALXH
Copy link

VIVALXH commented Aug 21, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

Version

Docker Image SHA:707f93473e7265df39593d38d83081ec1a6a36da31c97b391008858eb45a437f

kvrocks 镜像版本:sha256:707f93473e7265df39593d38d83081ec1a6a36da31c97b391008858eb45a437f

Minimal reproduce step

  1. kvrocks设置位图01011000对应字母X:
    redis-cli -h 192.168.1.72 -p 6666
    192.168.1.72:6666> flushdb
    OK
    192.168.1.72:6666> SETBIT A 0 0
    (integer) 0
    192.168.1.72:6666> SETBIT A 1 1
    (integer) 0
    192.168.1.72:6666> SETBIT A 2 0
    (integer) 0
    192.168.1.72:6666> SETBIT A 3 1
    (integer) 0
    192.168.1.72:6666> SETBIT A 4 1
    (integer) 0
    192.168.1.72:6666> SETBIT A 5 0
    (integer) 0
    192.168.1.72:6666> SETBIT A 6 0
    (integer) 0
    192.168.1.72:6666> SETBIT A 7 0
    (integer) 0
    192.168.1.72:6666> GET A
    "X"
    192.168.1.72:6666> bitfield A get u7 0
  1. (integer) 13
  1. redis设置位图01011000对应字母X:
    redis-cli -h 192.168.1.72 -p 6379
    192.168.1.72:6379> flushdb
    OK
    192.168.1.72:6379> SETBIT A 0 0
    (integer) 0
    192.168.1.72:6379> SETBIT A 1 1
    (integer) 0
    192.168.1.72:6379> SETBIT A 2 0
    (integer) 0
    192.168.1.72:6379> SETBIT A 3 1
    (integer) 0
    192.168.1.72:6379> SETBIT A 4 1
    (integer) 0
    192.168.1.72:6379> SETBIT A 5 0
    (integer) 0
    192.168.1.72:6379> SETBIT A 6 0
    (integer) 0
    192.168.1.72:6379> SETBIT A 7 0
    (integer) 0
    192.168.1.72:6379> GET A
    "X"
    192.168.1.72:6379> bitfield A get u7 0
  1. (integer) 44

What did you expect to see?

设置位图01011000对应字母X,通过bitfield从0偏移量获取7位,kvrocks结果是13(0001101),redis是44(0101100),从bitfield定义中,预期应该是redis对应的结果。

What did you see instead?

Anything Else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@VIVALXH VIVALXH added the bug type bug label Aug 21, 2024
@mapleFU
Copy link
Member

mapleFU commented Aug 21, 2024

Will check this later today

@git-hulk git-hulk changed the title bitfield get命令与redis结果不一致 Inconsistent behavior with Redis in BITFIELD GET command Aug 21, 2024
@mapleFU
Copy link
Member

mapleFU commented Aug 21, 2024

kvrocks bitmap uses LSB here, and MSB is used in redis...This is the root cause of this problem

I would try to fix the bitfield, but "get" would not gurantee to be same as redis.

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

No branches or pull requests

2 participants