Skip to content

Conversation

pro-spild
Copy link
Collaborator

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进行一致性测试,结果均一致。

Copy link

coderabbitai bot commented Dec 24, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added Invalid PR Title ✏️ Feature New feature or request 📒 Documentation Improvements or additions to documentation labels Dec 24, 2024
@pro-spild pro-spild changed the title feature: migrate tools support pika v3.5.0 feat: migrate tools support pika v3.5.0 Dec 24, 2024
@pro-spild pro-spild force-pushed the pika-migrate-v3.5.0 branch from 188566a to e744786 Compare January 6, 2025 09:03
s = cli_->Recv(&resp);
if (resp[0] == "OK") {
} else {
LOG(FATAL) << "Connect to redis(" << ip_ << ":" << port_ << ") Invalid password";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FATAL级别的日志会直接abort进程,所以我理解这个地方打印个ERROR的日志加重试吧。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以修改为ERROR

s = cli_->Recv(&resp);
if (s.ok()) {
if (resp[0] == "NOAUTH Authentication required.") {
LOG(FATAL) << "Ping redis(" << ip_ << ":" << port_ << ") NOAUTH Authentication required";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,FATAL级别日志会导致进程直接退出

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

elements_--;
LoadKey(key);
cli_->Close();
LOG(INFO) << s.ToString().data();
Copy link
Collaborator

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和类型,而且是需要一直重试直到成功的,要不就丢数据了。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里失败会调用LoadKey将key重新存到缓冲区,等待下次重新发送

if (!s.ok()) {
delete cli_;
cli_ = NULL;
LOG(WARNING) << "Can not connect to " << ip_ << ":" << port_ << ", status: " << s.ToString();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是connect失败需要一直重试的话,我理解重试connect即可,感觉不需要重新new对象。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done
将connectRedis的逻辑修改为重新connect,cli_初始化放在pikaSender构造函数中

pstd::Status s = cli_->Send(&cmd);

if (s.ok()) {
s = cli_->Recv(&resp);
Copy link
Collaborator

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();
Copy link
Collaborator

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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete cli_


// pika-migrate-tool only support 1 db
if (databases_ != 1) {
LOG(FATAL) << "pika-migrate-tool only support 1 db";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块会导致CI过不了
还有个问题:现在pika默认配置就是3db、一般线上都是6db,这种情况怎么处理合适?

@wangshao1
Copy link
Collaborator

刚发现,你的改动好像是在pika/src或者是pika/include下,是不应该修改 pika/tools/migrate_tool下呢?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I just found out that your changes seem to be under pika/src or pika/include. Shouldn't you modify pika/tools/migrate_tool?

@pro-spild
Copy link
Collaborator Author

刚发现,你的改动好像是在pika/src或者是pika/include下,是不应该修改 pika/tools/migrate_tool下呢?
3.5当时直接在src下面改了,我不知道重新commit会不会导致你以前的review记录没了,所以想着review结束了再和4.0一样放到tools下面。当时unstable分支下面有这个工具,3.5没有,我就直接在src下面改了。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I just found out that your changes seem to be under pika/src or pika/include. Shouldn't you modify pika/tools/migrate_tool?
3.5 was changed directly under src at that time. I don’t know if recommit will cause your previous review record to be lost, so I thought that after the review ended, I put it under tools like 4.0. At that time, there was this tool under the unstable branch, but it didn't have it in 3.5, so I changed it directly under src.

@guozhihao-224
Copy link

这里我尝试使用该工具进行迁移,发现其仅将sst文件下载到migrate-tool本地,但是没有将命令转发给下游

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Here I tried to use the tool for migration and found that it only downloads the sst file to migrate-tool locally, but does not forward the command to the downstream

@pro-spild
Copy link
Collaborator Author

这里我尝试使用该工具进行迁移,发现其仅将sst文件下载到migrate-tool本地,但是没有将命令转发给下游

@guozhihao-224 可以贴一下pika_migrate用的conf吗?还有使用场景是啥样的呢?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Here I tried using the tool for migration and found that it only downloads the sst file to migrate-tool locally, but does not forward the command to the downstream

@guozhihao-224 Can you post the conf used for pika_migrate? What are the usage scenarios?

@guozhihao-224
Copy link

guozhihao-224 commented Mar 4, 2025

这里我尝试使用该工具进行迁移,发现其仅将 sst 文件下载到 migrate-tool 本地,但是没有将命令转发给下游

@guozhihao-224可以贴一下pika_migrate用的conf吗?还有使用场景是啥样的呢?
是pika3.5.5 迁移到 3.5.5版本,100GB量级的数据

这里测试后,发现有将命令往下转发给下游,但是我发现,设置redis-sender-num大于8的话,就会在转发一部分数据后卡住不动了,设置成其他值会的比如5 — 8 之间,也会突然出现卡住不执行的状态。有试过设置为2能够跑完迁移任务,但是设置为2后,迁移时间太长了,100GB的数据的迁移1个多小时

是否有死锁的情况出现
对应的conf:
pika-migrate.txt

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Here I tried using the tool for migration and found that it only downloads the sst file to migrate-tool locally, but does not forward the command to the downstream

@guozhihao-224 Can you post the conf used by pika_migrate? What are the usage scenarios?
After testing here, I found that the command is forwarded downstream to the downstream, but I found that if the redis-sender-num is greater than 8, it will be stuck after forwarding part of the data, but there is no problem with setting 8. This may be due to the influence of that direction setting.

Corresponding conf:
pika-migrate.txt

@wangshao1 wangshao1 requested a review from baixin01 March 7, 2025 10:10
@pro-spild
Copy link
Collaborator Author

这里我尝试使用该工具进行迁移,发现其仅将 sst 文件下载到 migrate-tool 本地,但是没有将命令转发给下游

@guozhihao-224可以贴一下pika_migrate用的conf吗?还有使用场景是啥样的呢?
是pika3.5.5 迁移到 3.5.5版本,100GB量级的数据

这里测试后,发现有将命令往下转发给下游,但是我发现,设置redis-sender-num大于8的话,就会在转发一部分数据后卡住不动了,设置成其他值会的比如5 — 8 之间,也会突然出现卡住不执行的状态。有试过设置为2能够跑完迁移任务,但是设置为2后,迁移时间太长了,100GB的数据的迁移1个多小时

是否有死锁的情况出现 对应的conf: pika-migrate.txt

这边可能还需要提供一下pika_migrate的日志,我这边测试5-8之间同量级的数据均没有出现卡住的情况。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Here I tried using the tool for migration and found that it only downloads the sst file to migrate-tool locally, but does not forward the command to the downstream

@guozhihao-224 Can you post the conf used by pika_migrate? What are the usage scenarios?
is pika3.5.5 migrated to 3.5.5 version, 100GB data

After testing here, I found that the command is forwarded downstream to the downstream, but I found that if the redis-sender-num is greater than 8, it will be stuck after forwarding part of the data. If the setting to other values, such as between 5 and 8, it will suddenly become stuck and not executed. I have tried setting it to 2 to complete the migration task, but after setting it to 2, the migration time is too long, and the migration of 100GB of data will take more than an hour.

Whether there is a deadlock? Corresponding conf: pika-migrate.txt

Here, you may also need to provide the log of pika_migrate. I tested that the data of the same magnitude between 5-8 did not get stuck.

@chejinge chejinge changed the base branch from 3.5 to pika-migrate-v3.5 August 28, 2025 06:45
@chejinge
Copy link
Collaborator

创建了新的分支,pr就不会有这么多文件修改和冲突,功能完成之后编译出二进制再放入migrate_tool,已经新建分支

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


After creating a new branch, there will be no so many file modifications and conflicts in pr. After the function is completed, compile the binary and put it in migrate_tool. A new branch has been created.

@chejinge chejinge merged commit bd84cf7 into OpenAtomFoundation:pika-migrate-v3.5 Sep 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📒 Documentation Improvements or additions to documentation ✏️ Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants