AddTeamsBestOf: Build more teams than desired

We build more teams than we finally want so that we can use serverTeamRemover() actor to remove the teams
whose member belong to too many teams. This allows us to get a more balanced number of teams per server.
This commit is contained in:
Meng Xu 2019-07-02 17:39:04 -07:00
parent 7afbd10a10
commit 7461c87ae6
1 changed files with 11 additions and 2 deletions

View File

@ -1842,8 +1842,17 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
// If there are too few machines to even build teams or there are too few represented datacenters, build no new teams
if( uniqueMachines >= self->configuration.storageTeamSize ) {
desiredTeams = SERVER_KNOBS->DESIRED_TEAMS_PER_SERVER*serverCount;
int maxTeams = SERVER_KNOBS->MAX_TEAMS_PER_SERVER*serverCount;
// We build more teams than we finally want so that we can use serverTeamRemover() actor to remove the teams
// whose member belong to too many teams. This allows us to get a more balanced number of teams per server.
// The numTeamsPerServerFactor is calculated as
// (SERVER_KNOBS->DESIRED_TEAMS_PER_SERVER + ideal_num_of_teams_per_server) / 2
// ideal_num_of_teams_per_server is (#teams * storageTeamSize) / #servers, which is
// (#servers * DESIRED_TEAMS_PER_SERVER * storageTeamSize) / #servers.
int numTeamsPerServerFactor = (SERVER_KNOBS->DESIRED_TEAMS_PER_SERVER + SERVER_KNOBS->DESIRED_TEAMS_PER_SERVER * self->configuration.storageTeamSize) / 2;
ASSERT(SERVER_KNOBS->DESIRED_TEAMS_PER_SERVER >= 1 && self->configuration.storageTeamSize >= 1);
ASSERT(numTeamsPerServerFactor > 0);
desiredTeams = numTeamsPerServerFactor * serverCount;
int maxTeams = numTeamsPerServerFactor * serverCount;
// Exclude teams who have members in the wrong configuration, since we don't want these teams
int teamCount = 0;