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 JSON.MSET command #2552

Closed
2 tasks done
VIVALXH opened this issue Sep 23, 2024 · 4 comments
Closed
2 tasks done

Inconsistent behavior with Redis in JSON.MSET command #2552

VIVALXH opened this issue Sep 23, 2024 · 4 comments
Labels
bug type bug

Comments

@VIVALXH
Copy link

VIVALXH commented Sep 23, 2024

Search before asking

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

Version

redis:
image: redislabs/rejson:latest

kvrocks:
image: apache/kvrocks:latest

Minimal reproduce step

redis:
image: redislabs/rejson:latest

❯ redis-cli -h 192.168.1.72 -p 6369
192.168.1.72:6369> flushdb
OK
192.168.1.72:6369> JSON.SET doc $ '{"f1":{"a1":0},"f2":{"a2":0}}'
OK
192.168.1.72:6369> JSON.GET doc
"{\"f1\":{\"a1\":0},\"f2\":{\"a2\":0}}"
192.168.1.72:6369> JSON.MSET doc $.f1.a1 1 doc $.f2.a2 2
OK
192.168.1.72:6369> JSON.GET doc
"{\"f1\":{\"a1\":1},\"f2\":{\"a2\":2}}"

kvrocks:
image: apache/kvrocks:latest

❯ redis-cli -h 192.168.1.72 -p 6666
192.168.1.72:6666> flushdb
OK
192.168.1.72:6666> JSON.SET doc $ '{"f1":{"a1":0},"f2":{"a2":0}}'
OK
192.168.1.72:6666> JSON.GET doc
"{\"f1\":{\"a1\":0},\"f2\":{\"a2\":0}}"
192.168.1.72:6666> JSON.MSET doc $.f1.a1 1 doc $.f2.a2 2
OK
192.168.1.72:6666> JSON.GET doc
"{\"f1\":{\"a1\":0},\"f2\":{\"a2\":2}}"

What did you expect to see?

I hope that the behavior of JSON.MSET in KVROCKS is consistent with Redis.

What did you see instead?

For Redis, the JSON.MSET command can modify multiple fields of the same key simultaneously, but for KVROCKS, only one field is successfully modified.

Anything Else?

I found that in the code, JSON.MSET performs a query for each sub-command, resulting in a separate result in memory for each key if the keys are the same. Can it be modified so that there is only one copy of the key in memory and no repeated reads?
https://github.com/apache/kvrocks/blob/f2bc224bc342f7e2b679cb2dc79d7a31067643ca/src/types/redis_json.cc#L579C15-L579C17

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@VIVALXH VIVALXH added the bug type bug label Sep 23, 2024
@git-hulk
Copy link
Member

@VIVALXH Good catch, would you like to fix this?

@VIVALXH
Copy link
Author

VIVALXH commented Sep 24, 2024

Thank you for your response and for recognizing the issue. I'd be happy to try and fix this issue, and I plan to start working after my workday.

@git-hulk
Copy link
Member

@VIVALXH Thank you!

@PragmaTwice PragmaTwice changed the title Inconsistent behavior with Redis in JSON,MSET command Inconsistent behavior with Redis in JSON.MSET command Oct 5, 2024
@PragmaTwice
Copy link
Member

Fixed in #2579.

@VIVALXH VIVALXH removed their assignment Oct 5, 2024
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

3 participants