-
Notifications
You must be signed in to change notification settings - Fork 452
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
Add the support of the load RDB command #1798
Conversation
Hi @xq2010 Thanks for your excellent contribution first! About how to load the RDB file, I'm wondering if it's better to export a command to do this. For example, we can support a new command like $ redis-cli 6666> load RDB /path/to/your/rdb_file So that we don't need to introduce a new tool. How do you feel about this? cc @apache/kvrocks-committers |
If we add the 'load rdb' command, we need to determine how to process an existing key that's present in both kvrocks and rdb, particularly when the key's type is a string in rdb. It will overwrite the existing key in kvrocks, which may be of a different type." |
Yes, it's a good concern. I prefer overwriting by default if it exists and we can offer an option NX like the set command to let users determine in the future. This is my personal perspective, would like to hear more voices about the loading way design. |
Using NX is a good idea, I would also like to hear more opinions. |
Thanks for your contribution! Agree with @git-hulk, I think it would be better to just implement it like a command inside the kvrocks process instead of a new program. |
@git-hulk @PragmaTwice Okay, I will add a command to load the RDB file. The command might be rdb load <path> [namespace]. Do you have any suggestions or advice? |
Thank you! Sounds good to me, but [namespace] seems unnecessary since it knows the current namespace once it enters the command. |
Yes, it's unnecessary to use a namespace. If the RDB file contains multiple db, the current implementation sets the namespace of each db to <ns>_<db number>. The password will be the same as the namespace. Only db 0 will use the current namespace. |
@xq2010 Yes, I think this is a good solution. |
… to load rdb file, delete redis2kvrocks and rdb files
@xq2010 Cool! The overall design is nice. I'll take another pass to take a look at detail implementation tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good. But I don't have time to check in details for giving an approval on the implementation 🤣
…efactor rdb_test, and remove testdatas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xq2010 Good job, thank you for your effort. Just a little nitpicking from me :)
Thanks for your review, I will review it later |
Hi @xq2010 How's this PR going? Should we take another round review? |
@git-hulk Thank you for your review. I've made some corrections. Could you please review it once more? |
Sure, thanks for your efforts! |
I would like to merge this PR today if no more comments. |
I'm a bit busy these few days. I'll go through it before Thursday. You can merge this first if other doesn't have any comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, LGTM.
#include "fmt/format.h" | ||
#include "vendor/crc64.h" | ||
|
||
StatusOr<size_t> RdbStringStream::Read(char *buf, size_t n) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syntax of RdbStringStream
is different from RdbFileStream
. The previous one will return a smaller size when n is greater than remaining buffer, but RdbFileStream
will always return Status::NotOK
. Is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I make it wrong. So they're same.
std::vector<char> vec(len); | ||
GET_OR_RET(stream_->Read(vec.data(), len)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be len == 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is possible, could you help me fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1839
I've create a pull request for it.
Thanks again for your contribution!
This PR is for #1753