-
Notifications
You must be signed in to change notification settings - Fork 488
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(cluster): should stop the migration if it's changed to the slave role #2716
Conversation
2091349
to
6b25971
Compare
@RiversJin Thanks for raising this issue. You're right that we should stop the migration while becoming to the slave role. |
src/cluster/cluster.cc
Outdated
if (myself_->role == kClusterMaster) { | ||
// Master mode | ||
auto s = srv_->RemoveMaster(); | ||
if (!s.IsOK()) { | ||
return s.Prefixed("failed to remove master"); | ||
} | ||
LOG(INFO) << "MASTER MODE enabled by cluster topology setting"; | ||
} else if (nodes_.find(myself_->master_id) != nodes_.end()) { | ||
if (is_slave && is_cluster_enabled) { |
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.
if (is_slave && is_cluster_enabled) { | |
if (is_slave && is_cluster_enabled && srv_->slot_migrator) { |
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 slot_migrator might be null pointer while starting the server.
src/cluster/cluster.cc
Outdated
if (is_slave && is_cluster_enabled) { | ||
// Slave -> Master | ||
srv_->slot_migrator->SetStopMigrationFlag(false); | ||
LOG(INFO) << "Change server role to master, stop migration task"; |
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.
Wrong log message, it should restart the migration task instead of the stop.
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.
oops... fixed
src/cluster/cluster.cc
Outdated
auto s = srv_->AddMaster(master->host, master->port, false); | ||
if (!s.IsOK()) { | ||
LOG(WARNING) << "SLAVE OF " << master->host << ":" << master->port | ||
<< " wasn't enabled by cluster topology setting, encounter error: " << s.Msg(); | ||
return s.Prefixed("failed to add master"); | ||
} | ||
LOG(INFO) << "SLAVE OF " << master->host << ":" << master->port << " enabled by cluster topology setting"; | ||
if (!is_slave && is_cluster_enabled) { |
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.
if (!is_slave && is_cluster_enabled) { | |
if (!is_slave && is_cluster_enabled && srv_->slot_migrator) { |
f0a4446
to
eb331f8
Compare
Quality Gate passedIssues Measures |
In cluster mode, if a master-slave failover occurs, it seems that slot migration is not properly stopped. However, the slave of command has corresponding update logic. So, this is a bug, right?