-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: migrate tools support pika v3.5.0 #2984
base: 3.5
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
188566a
to
e744786
Compare
int timestamp = std::atoi(argv[2].data()); | ||
std::string value = argv[3]; | ||
|
||
int seconds = timestamp - time(NULL); |
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.
这个地方会不会溢出?
s = cli_->Recv(&resp); | ||
if (resp[0] == "OK") { | ||
} else { | ||
LOG(FATAL) << "Connect to redis(" << ip_ << ":" << port_ << ") Invalid password"; |
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.
FATAL级别的日志会直接abort进程,所以我理解这个地方打印个ERROR的日志加重试吧。
s = cli_->Recv(&resp); | ||
if (s.ok()) { | ||
if (resp[0] == "NOAUTH Authentication required.") { | ||
LOG(FATAL) << "Ping redis(" << ip_ << ":" << port_ << ") NOAUTH Authentication required"; |
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.
同上,FATAL级别日志会导致进程直接退出
elements_--; | ||
LoadKey(key); | ||
cli_->Close(); | ||
LOG(INFO) << s.ToString().data(); |
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.
LOG(INFO)<< s.ToString()就可以了.
另外,这里应该得判断下返回值,如果返回结果不符合预期,我理解需要打印出具体失败的key和类型,而且是需要一直重试直到成功的,要不就丢数据了。
if (!s.ok()) { | ||
delete cli_; | ||
cli_ = NULL; | ||
LOG(WARNING) << "Can not connect to " << ip_ << ":" << port_ << ", status: " << s.ToString(); |
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.
如果是connect失败需要一直重试的话,我理解重试connect即可,感觉不需要重新new对象。
pstd::Status s = cli_->Send(&cmd); | ||
|
||
if (s.ok()) { | ||
s = cli_->Recv(&resp); |
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.
auth返回值是不是需要判断下,如果是穿的密码是错的,就不用重试了。
LOG(INFO) << "Start sender thread..."; | ||
|
||
if (cli_ == NULL) { | ||
ConnectRedis(); |
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.
如果ConnectRedis返回时,cli不能保证一定初始化成功,那我理解你在外面就需要考虑cli是空指针的问题。或者你就直接让进程退出,比如auth 命令返回密码错误,或者服务端需要auth但migrate启动的时候没有设置密码,这种直接就进程退出。
return 0; | ||
} | ||
|
||
cli_->Close(); |
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.
delete cli_
feature
pika-migrate-tools支持3.5.0。
Test
写入SET/HSET/LPUSH/SADD/ZADD 各10000000条,然后运行migrate-tool。在迁移期间写入/DEL/HDEL/LPOP/SREM/ZREM各5000000条。在sourceDB和targetDB对操作的key进行一致性测试,结果均一致。