Skip to content

Commit

Permalink
[suqash me] fix slot_migrator null
Browse files Browse the repository at this point in the history
  • Loading branch information
RiversJin committed Jan 8, 2025
1 parent c69765f commit f0a4446
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cluster/cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ Status Cluster::SetMasterSlaveRepl() {
return s.Prefixed("failed to remove master");
}
LOG(INFO) << "MASTER MODE enabled by cluster topology setting";
if (is_slave && is_cluster_enabled) {
if (srv_->slot_migrator && is_cluster_enabled && is_slave) {
// Slave -> Master
srv_->slot_migrator->SetStopMigrationFlag(false);
LOG(INFO) << "Change server role to master, stop migration task";
LOG(INFO) << "Change server role to master, restart migration task";
}
return Status::OK();
}
Expand All @@ -265,7 +265,7 @@ Status Cluster::SetMasterSlaveRepl() {
<< " wasn't enabled by cluster topology setting, encounter error: " << s.Msg();
return s.Prefixed("failed to add master");
}
if (!is_slave && is_cluster_enabled) {
if (srv_->slot_migrator && is_cluster_enabled && !is_slave) {
// Master -> Slave
srv_->slot_migrator->SetStopMigrationFlag(true);
LOG(INFO) << "Change server role to slave, stop migration task";
Expand Down

0 comments on commit f0a4446

Please sign in to comment.