diff --git a/fdbserver/ClusterController.actor.cpp b/fdbserver/ClusterController.actor.cpp index f3d8b2167b..60f45d0d5c 100644 --- a/fdbserver/ClusterController.actor.cpp +++ b/fdbserver/ClusterController.actor.cpp @@ -196,21 +196,9 @@ struct EncryptKeyProxySingleton : Singleton { } }; -ACTOR Future handleLeaderReplacement(Reference self, Future leaderFail) { - loop choose { - when(wait(leaderFail)) { - TraceEvent("LeaderReplaced", self->controllerData->id).log(); - // We are no longer the leader if this has changed. - self->controllerData->shouldCommitSuicide = true; - throw restart_cluster_controller(); - } - } -} - ACTOR Future clusterWatchDatabase(ClusterControllerData* cluster, ClusterControllerData::DBInfo* db, ServerCoordinators coordinators, - Future leaderFail, Future recoveredDiskFiles) { state MasterInterface iMaster; state Reference recoveryData; @@ -307,7 +295,6 @@ ACTOR Future clusterWatchDatabase(ClusterControllerData* cluster, TraceEvent(SevDebug, "BackupWorkerDoneRequest", cluster->id).log(); } when(wait(collection)) { throw internal_error(); } - when(wait(handleLeaderReplacement(recoveryData, leaderFail))) { throw internal_error(); } } // failed master (better master exists) could happen while change-coordinators request processing is // in-progress @@ -2558,8 +2545,8 @@ ACTOR Future clusterControllerCore(ClusterControllerFullInterface interf, if (SERVER_KNOBS->ENABLE_ENCRYPTION) { self.addActor.send(monitorEncryptKeyProxy(&self)); } - self.addActor.send(clusterWatchDatabase( - &self, &self.db, coordinators, leaderFail, recoveredDiskFiles)); // Start the master database + self.addActor.send( + clusterWatchDatabase(&self, &self.db, coordinators, recoveredDiskFiles)); // Start the master database self.addActor.send(self.updateWorkerList.init(self.db.db)); self.addActor.send(statusServer(interf.clientInterface.databaseStatus.getFuture(), &self, @@ -2669,6 +2656,12 @@ ACTOR Future clusterControllerCore(ClusterControllerFullInterface interf, when(GetServerDBInfoRequest req = waitNext(interf.getServerDBInfo.getFuture())) { self.addActor.send(clusterGetServerInfo(&self.db, req.knownServerInfoID, req.reply)); } + when(wait(leaderFail)) { + // We are no longer the leader if this has changed. + endRole(Role::CLUSTER_CONTROLLER, interf.id(), "Leader Replaced", true); + CODE_PROBE(true, "Leader replaced"); + return Void(); + } when(ReplyPromise ping = waitNext(interf.clientInterface.ping.getFuture())) { ping.send(Void()); } } }