From 14c8483e9dd1a1ec149c20aabeae16f659e2d22e Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Thu, 10 Feb 2022 18:16:57 -0800 Subject: [PATCH] Mark DDTeamCollection::primary private --- fdbserver/DDTeamCollection.actor.cpp | 2 +- fdbserver/DDTeamCollection.h | 6 ++-- fdbserver/DataDistribution.actor.cpp | 47 ++++++++++++++-------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/fdbserver/DDTeamCollection.actor.cpp b/fdbserver/DDTeamCollection.actor.cpp index 9e09f18044..ca85a9034b 100644 --- a/fdbserver/DDTeamCollection.actor.cpp +++ b/fdbserver/DDTeamCollection.actor.cpp @@ -3333,7 +3333,7 @@ DDTeamCollection::DDTeamCollection(Database const& cx, teamCollectionInfoEventHolder(makeReference("TeamCollectionInfo")), storageServerRecruitmentEventHolder( makeReference("StorageServerRecruitment_" + distributorId.toString())), - cx(cx), distributorId(distributorId), configuration(configuration), primary(primary), + primary(primary), cx(cx), distributorId(distributorId), configuration(configuration), storageServerSet(new LocalityMap()) { if (!primary || configuration.usableRegions == 1) { TraceEvent("DDTrackerStarting", distributorId) diff --git a/fdbserver/DDTeamCollection.h b/fdbserver/DDTeamCollection.h index 0e83fe4eed..a441c78b7f 100644 --- a/fdbserver/DDTeamCollection.h +++ b/fdbserver/DDTeamCollection.h @@ -262,6 +262,8 @@ class DDTeamCollection : public ReferenceCounted { Reference teamCollectionInfoEventHolder; Reference storageServerRecruitmentEventHolder; + bool primary; + // Randomly choose one machine team that has chosenServer and has the correct size // When configuration is changed, we may have machine teams with old storageTeamSize Reference findOneRandomMachineTeam(TCServerInfo const& chosenServer) const; @@ -532,8 +534,6 @@ public: std::vector> teams; - bool primary; - std::vector teamCollections; AsyncTrigger printDetailedTeamsInfo; Reference storageServerSet; @@ -648,6 +648,8 @@ public: // valid bool exclusionSafetyCheck(std::vector& excludeServerIDs); + bool isPrimary() const { return primary; } + // Keep track of servers and teams -- serves requests for getRandomTeam static Future run(Reference teamCollection, Reference initData, diff --git a/fdbserver/DataDistribution.actor.cpp b/fdbserver/DataDistribution.actor.cpp index 053e01e5cd..2e4b2b1be3 100644 --- a/fdbserver/DataDistribution.actor.cpp +++ b/fdbserver/DataDistribution.actor.cpp @@ -238,7 +238,8 @@ ACTOR Future> getInitialDataDistribution(Data // add server to wiggling queue void StorageWiggler::addServer(const UID& serverId, const StorageMetadataType& metadata) { - // std::cout << "size: " << pq_handles.size() << " add " << serverId.toString() << " DC: "<< teamCollection->primary + // std::cout << "size: " << pq_handles.size() << " add " << serverId.toString() << " DC: "<< + // teamCollection->isPrimary() // << std::endl; ASSERT(!pq_handles.count(serverId)); pq_handles[serverId] = wiggle_pq.emplace(metadata, serverId); @@ -247,7 +248,7 @@ void StorageWiggler::addServer(const UID& serverId, const StorageMetadataType& m void StorageWiggler::removeServer(const UID& serverId) { // std::cout << "size: " << pq_handles.size() << " remove " << serverId.toString() << " DC: "<< - // teamCollection->primary <isPrimary() <primary << std::endl; + // << " DC: " << teamCollection->isPrimary() << std::endl; auto handle = pq_handles.at(serverId); if ((*handle).first.createdTime == metadata.createdTime) { return; @@ -280,7 +281,7 @@ Future StorageWiggler::resetStats() { auto newMetrics = StorageWiggleMetrics(); newMetrics.smoothed_round_duration = metrics.smoothed_round_duration; newMetrics.smoothed_wiggle_duration = metrics.smoothed_wiggle_duration; - return StorageWiggleMetrics::runSetTransaction(teamCollection->cx, teamCollection->primary, newMetrics); + return StorageWiggleMetrics::runSetTransaction(teamCollection->cx, teamCollection->isPrimary(), newMetrics); } Future StorageWiggler::restoreStats() { @@ -291,7 +292,7 @@ Future StorageWiggler::restoreStats() { } return Void(); }; - auto readFuture = StorageWiggleMetrics::runGetTransaction(teamCollection->cx, teamCollection->primary); + auto readFuture = StorageWiggleMetrics::runGetTransaction(teamCollection->cx, teamCollection->isPrimary()); return map(readFuture, assignFunc); } Future StorageWiggler::startWiggle() { @@ -299,7 +300,7 @@ Future StorageWiggler::startWiggle() { if (shouldStartNewRound()) { metrics.last_round_start = metrics.last_wiggle_start; } - return StorageWiggleMetrics::runSetTransaction(teamCollection->cx, teamCollection->primary, metrics); + return StorageWiggleMetrics::runSetTransaction(teamCollection->cx, teamCollection->isPrimary(), metrics); } Future StorageWiggler::finishWiggle() { @@ -314,7 +315,7 @@ Future StorageWiggler::finishWiggle() { duration = metrics.last_round_finish - metrics.last_round_start; metrics.smoothed_round_duration.setTotal((double)duration); } - return StorageWiggleMetrics::runSetTransaction(teamCollection->cx, teamCollection->primary, metrics); + return StorageWiggleMetrics::runSetTransaction(teamCollection->cx, teamCollection->isPrimary(), metrics); } // Take a snapshot of necessary data structures from `DDTeamCollection` and print them out with yields to avoid slow @@ -371,18 +372,18 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { TraceEvent("DDPrintSnapshotTeasmInfo", self->distributorId) .detail("SnapshotSpeed", now() - snapshotStart) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); // Print to TraceEvents TraceEvent("DDConfig", self->distributorId) .detail("StorageTeamSize", configuration.storageTeamSize) .detail("DesiredTeamsPerServer", SERVER_KNOBS->DESIRED_TEAMS_PER_SERVER) .detail("MaxTeamsPerServer", SERVER_KNOBS->MAX_TEAMS_PER_SERVER) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); TraceEvent("ServerInfo", self->distributorId) .detail("Size", server_info.size()) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); state int i; state std::map>::iterator server = server_info.begin(); for (i = 0; i < server_info.size(); i++) { @@ -391,7 +392,7 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { .detail("ServerID", server->first.toString()) .detail("ServerTeamOwned", server->second->teams.size()) .detail("MachineID", server->second->machine->machineID.contents().toString()) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); server++; if (++traceEventsPrinted % SERVER_KNOBS->DD_TEAMS_INFO_PRINT_YIELD_COUNT == 0) { wait(yield()); @@ -407,7 +408,7 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { .detail("MachineIsValid", server_info[uid]->machine.isValid()) .detail("MachineTeamSize", server_info[uid]->machine.isValid() ? server_info[uid]->machine->machineTeams.size() : -1) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); // ServerStatus might not be known if server was very recently added and storageServerFailureTracker() // has not yet updated self->server_status @@ -425,7 +426,7 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { TraceEvent("ServerTeamInfo", self->distributorId) .detail("Size", teams.size()) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); for (i = 0; i < teams.size(); i++) { const auto& team = teams[i]; TraceEvent("ServerTeamInfo", self->distributorId) @@ -433,7 +434,7 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { .detail("Healthy", team->isHealthy()) .detail("TeamSize", team->size()) .detail("MemberIDs", team->getServerIDsStr()) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); if (++traceEventsPrinted % SERVER_KNOBS->DD_TEAMS_INFO_PRINT_YIELD_COUNT == 0) { wait(yield()); } @@ -441,7 +442,7 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { TraceEvent("MachineInfo", self->distributorId) .detail("Size", machine_info.size()) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); state std::map, Reference>::iterator machine = machine_info.begin(); state bool isMachineHealthy = false; for (i = 0; i < machine_info.size(); i++) { @@ -470,7 +471,7 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { .detail("MachineTeamOwned", machine->second->machineTeams.size()) .detail("ServerNumOnMachine", machine->second->serversOnMachine.size()) .detail("ServersID", machine->second->getServersIDStr()) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); machine++; if (++traceEventsPrinted % SERVER_KNOBS->DD_TEAMS_INFO_PRINT_YIELD_COUNT == 0) { wait(yield()); @@ -479,14 +480,14 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { TraceEvent("MachineTeamInfo", self->distributorId) .detail("Size", machineTeams.size()) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); for (i = 0; i < machineTeams.size(); i++) { const auto& team = machineTeams[i]; TraceEvent("MachineTeamInfo", self->distributorId) .detail("TeamIndex", i) .detail("MachineIDs", team->getMachineIDsStr()) .detail("ServerTeams", team->serverTeams.size()) - .detail("Primary", self->primary); + .detail("Primary", self->isPrimary()); if (++traceEventsPrinted % SERVER_KNOBS->DD_TEAMS_INFO_PRINT_YIELD_COUNT == 0) { wait(yield()); } @@ -495,12 +496,12 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { // TODO: re-enable the following logging or remove them. // TraceEvent("LocalityRecordKeyName", self->distributorId) // .detail("Size", internedLocalityRecordKeyNameStrings.size()) - // .detail("Primary", self->primary); + // .detail("Primary", self->isPrimary()); // for (i = 0; i < internedLocalityRecordKeyNameStrings.size(); i++) { // TraceEvent("LocalityRecordKeyIndexName", self->distributorId) // .detail("KeyIndex", i) // .detail("KeyName", internedLocalityRecordKeyNameStrings[i]) - // .detail("Primary", self->primary); + // .detail("Primary", self->isPrimary()); // if (++traceEventsPrinted % SERVER_KNOBS->DD_TEAMS_INFO_PRINT_YIELD_COUNT == 0) { // wait(yield()); // } @@ -508,7 +509,7 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { // TraceEvent("MachineLocalityMap", self->distributorId) // .detail("Size", machineLocalityMapEntryArraySize) - // .detail("Primary", self->primary); + // .detail("Primary", self->isPrimary()); // for (i = 0; i < serverIDs.size(); i++) { // const auto& serverID = serverIDs[i]; // Reference record = machineLocalityMapRecordArray[i]; @@ -517,13 +518,13 @@ ACTOR Future printSnapshotTeamsInfo(Reference self) { // .detail("LocalityIndex", i) // .detail("UID", serverID->toString()) // .detail("LocalityRecord", record->toString()) - // .detail("Primary", self->primary); + // .detail("Primary", self->isPrimary()); // } else { // TraceEvent("MachineLocalityMap", self->distributorId) // .detail("LocalityIndex", i) // .detail("UID", serverID->toString()) // .detail("LocalityRecord", "[NotFound]") - // .detail("Primary", self->primary); + // .detail("Primary", self->isPrimary()); // } // if (++traceEventsPrinted % SERVER_KNOBS->DD_TEAMS_INFO_PRINT_YIELD_COUNT == 0) { // wait(yield());