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

fix: slaveof return #2158

Closed

Conversation

callme-taota
Copy link
Contributor

@callme-taota callme-taota commented Nov 22, 2023

背景

ISSUES #1965

  1. 一个集群的从节点 slaveof 另一个集群的从节点
  2. 一个集群的从节点 slaveof 另一个集群的主节点
  3. 两个节点的 replicationID 非空且不一致,双方 slaveof

1和2可以看做为只要是从节点,再执行关于slaveof命令时,就返回错误
3的本质就是前面都包含了,我们规定是一个集群内的replicationid保持一致,如果replicationid不一致那么一定不是一个集群的

@callme-taota callme-taota marked this pull request as ready for review November 22, 2023 08:53
@callme-taota callme-taota changed the title Fix : salveof return Fix : slaveof return Nov 22, 2023
@@ -121,6 +121,11 @@ void SlaveofCmd::DoInitial() {
return;
}

if((g_pika_server->role() & PIKA_ROLE_SLAVE) != 0 && master_ip_ != g_pika_server->host() && master_port_ != g_pika_server->port()) {
res_.SetRes(CmdRes::kErrOther, "Not the same master,please use salveof no one to return the single mode before binding to other cluster.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

一个小建议,符号后面留一个空格master, please

Copy link
Collaborator

Choose a reason for hiding this comment

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

还有if ()也需要一个空格

@callme-taota
Copy link
Contributor Author

目前问题是,如果一个集群里进行切主操作,那么这段代码就会返回错误,所以应该要找codis那层的逻辑

@baerwang baerwang changed the title Fix : slaveof return fix : slaveof return Nov 23, 2023
@baerwang baerwang changed the title fix : slaveof return fix: slaveof return Nov 23, 2023
@baerwang baerwang added the ☢️ Bug Something isn't working label Nov 23, 2023
@AlexStocks
Copy link
Contributor

需要参照 Codis 的逻辑继续改进

@AlexStocks
Copy link
Contributor

wxr:需要跟一哥再讨论下

@Mixficsol Mixficsol closed this Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.5.3 ☢️ Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants