MCPcopy Create free account
hub / github.com/apple/foundationdb / removeServer

Method removeServer

fdbserver/DDTeamCollection.actor.cpp:4933–5046  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4931}
4932
4933void DDTeamCollection::removeServer(UID removedServer) {
4934 TraceEvent("RemovedStorageServer", distributorId).detail("ServerID", removedServer);
4935
4936 // ASSERT( !shardsAffectedByTeamFailure->getServersForTeam( t ) for all t in teams that contain removedServer )
4937 Reference<TCServerInfo> removedServerInfo = server_info[removedServer];
4938 // Step: Remove TCServerInfo from storageWiggler
4939 storageWiggler->removeServer(removedServer);
4940
4941 // Step: Remove server team that relate to removedServer
4942 // Find all servers with which the removedServer shares teams
4943 std::set<UID> serversWithAjoiningTeams;
4944 auto const& sharedTeams = removedServerInfo->getTeams();
4945 for (int i = 0; i < sharedTeams.size(); ++i) {
4946 auto& teamIds = sharedTeams[i]->getServerIDs();
4947 serversWithAjoiningTeams.insert(teamIds.begin(), teamIds.end());
4948 }
4949 serversWithAjoiningTeams.erase(removedServer);
4950
4951 // For each server in a team with the removedServer, erase shared teams from the list of teams in that other
4952 // server
4953 for (auto it = serversWithAjoiningTeams.begin(); it != serversWithAjoiningTeams.end(); ++it) {
4954 server_info[*it]->removeTeamsContainingServer(removedServer);
4955 }
4956
4957 // Step: Remove all teams that contain removedServer
4958 // SOMEDAY: can we avoid walking through all teams, since we have an index of teams in which removedServer
4959 // participated
4960 int removedCount = 0;
4961 for (int t = 0; t < teams.size(); t++) {
4962 if (std::count(teams[t]->getServerIDs().begin(), teams[t]->getServerIDs().end(), removedServer)) {
4963 TraceEvent("ServerTeamRemoved")
4964 .detail("Primary", primary)
4965 .detail("TeamServerIDs", teams[t]->getServerIDsStr())
4966 .detail("TeamID", teams[t]->getTeamID());
4967 // removeTeam also needs to remove the team from the machine team info.
4968 removeTeam(teams[t]);
4969 t--;
4970 removedCount++;
4971 }
4972 }
4973
4974 if (removedCount == 0) {
4975 TraceEvent(SevInfo, "NoTeamsRemovedWhenServerRemoved")
4976 .detail("Primary", primary)
4977 .detail("Debug", "ThisShouldRarelyHappen_CheckInfoBelow");
4978 }
4979
4980 for (int t = 0; t < badTeams.size(); t++) {
4981 if (std::count(badTeams[t]->getServerIDs().begin(), badTeams[t]->getServerIDs().end(), removedServer)) {
4982 badTeams[t]->tracker.cancel();
4983 badTeams[t--] = badTeams.back();
4984 badTeams.pop_back();
4985 }
4986 }
4987
4988 // Step: Remove machine info related to removedServer
4989 // Remove the server from its machine
4990 Reference<TCMachineInfo> removedMachineInfo = removedServerInfo->machine;

Callers 1

whenFunction · 0.45

Calls 15

TraceEventClass · 0.85
countFunction · 0.85
detailMethod · 0.80
getServerIDsStrMethod · 0.80
isUnhealthyMethod · 0.80
cancelMethod · 0.65
getMethod · 0.65
clearMethod · 0.65
sizeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected