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 when using RESTORE with dumped negative integers #2546

Closed
1 of 2 tasks
fstd2 opened this issue Sep 20, 2024 · 2 comments · Fixed by #2547
Closed
1 of 2 tasks

Inconsistent behavior when using RESTORE with dumped negative integers #2546

fstd2 opened this issue Sep 20, 2024 · 2 comments · Fixed by #2547
Labels
bug type bug

Comments

@fstd2
Copy link
Contributor

fstd2 commented Sep 20, 2024

Search before asking

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

Version

2.9.0

Minimal reproduce step

127.0.0.1:6666> set k -1
OK
127.0.0.1:6666> get k
"-1"
127.0.0.1:6666> dump k
"\x00\xc0\xff\x06\x00\x9a~\x16\xa4p]\xa1V"
127.0.0.1:6666> restore k1 0 "\x00\xc0\xff\x06\x00\x9a~\x16\xa4p]\xa1V"
OK
127.0.0.1:6666> get k1
"255"
127.0.0.1:6666> get k
"-1"
127.0.0.1:6666> set k2 -2
OK
127.0.0.1:6666> get k2
"-2"
127.0.0.1:6666> dump k2
"\x00\xc0\xfe\x06\x00$FVjY\x0c\xb3\xa2"
127.0.0.1:6666> restore k22 0 "\x00\xc0\xfe\x06\x00$FVjY\x0c\xb3\xa2"
OK
127.0.0.1:6666> get k2
"-2"
127.0.0.1:6666> get k22
"254"

What did you expect to see?

The value remains negative after RESTORE.

What did you see instead?

when restoring dumped negative integers, the values are restored as positive numbers (255 for -1 and 254 for -2).

Anything Else?

Possibly a problem with the following code?

kvrocks/src/storage/rdb.cc

Lines 158 to 160 in 2a0c57a

if (len == RDBEncInt8) {
auto next = GET_OR_RET(stream_->ReadByte());
return std::to_string(static_cast<int>(next));

Are you willing to submit a PR?

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

@fstd2 Good catch. Would you like to fix this?

@fstd2
Copy link
Contributor Author

fstd2 commented Sep 20, 2024

@git-hulk I'll try.

#2547

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

Successfully merging a pull request may close this issue.

2 participants