DD:ValidLocality:Resolve review comment

This commit is contained in:
Meng Xu 2019-09-13 15:34:41 -07:00
parent e1dcdbf3d2
commit 78b8e48cef
3 changed files with 10 additions and 14 deletions

View File

@ -180,8 +180,6 @@ public:
Optional<Standalone<StringRef>> dcId() const { return get(keyDcId); }
Optional<Standalone<StringRef>> dataHallId() const { return get(keyDataHallId); }
bool isValidLocalityValueUnderPolicy(std::string policy) { return get(policy).present(); }
std::string toString() const {
std::string infoString;
for (auto it = _data.rbegin(); !(it == _data.rend()); ++it) {

View File

@ -76,12 +76,8 @@ struct TCMachineInfo : public ReferenceCounted<TCMachineInfo> {
serversOnMachine.push_back(server);
LocalityData& locality = server->lastKnownInterface.locality;
if (locality.zoneId().present()) {
machineID = locality.zoneId().get();
} else {
// If locality is not set, the machine has only one server.
machineID = locality.processId().present() ? locality.processId().get() : StringRef(std::string(""));
}
ASSERT(locality.zoneId().present());
machineID = locality.zoneId().get();
}
std::string getServersIDStr() {
@ -1018,7 +1014,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
std::set<std::string> replicationPolicyKeys = storagePolicy->attributeKeys();
for (auto& policy : replicationPolicyKeys) {
if (!locality.isValidLocalityValueUnderPolicy(policy)) {
if (!locality.isPresent(policy)) {
return false;
}
}
@ -1448,8 +1444,9 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
if (!isMachineHealthy(machine.second)) continue;
// Skip machine with incomplete locality
if (!isValidLocality(configuration.storagePolicy,
machine.second->serversOnMachine[0]->lastKnownInterface.locality))
machine.second->serversOnMachine[0]->lastKnownInterface.locality)) {
continue;
}
// Invariant: We only create correct size machine teams.
// When configuration (e.g., team size) is changed, the DDTeamCollection will be destroyed and rebuilt
@ -1634,9 +1631,9 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
return deterministicRandom()->randomChoice(leastUsedServers);
}
// If we cannot find a healthy server with valid locality
TraceEvent("NoHealthyAndValidLocalityServer")
TraceEvent("NoHealthyAndValidLocalityServers")
.detail("Servers", server_info.size())
.detail("UnhealthServers", unhealthyServers);
.detail("UnhealthyServers", unhealthyServers);
return Reference<TCServerInfo>();
}
@ -3172,8 +3169,9 @@ ACTOR Future<KeyValueStoreType> keyValueStoreTypeTracker(DDTeamCollection* self,
(self->includedDCs.empty() ||
std::find(self->includedDCs.begin(), self->includedDCs.end(), server->lastKnownInterface.locality.dcId()) !=
self->includedDCs.end()) &&
(self->isValidLocality(self->configuration.storagePolicy, server->lastKnownInterface.locality)))
(self->isValidLocality(self->configuration.storagePolicy, server->lastKnownInterface.locality))) {
wait(Future<Void>(Never()));
}
return type;
}

View File

@ -187,7 +187,7 @@ ServerKnobs::ServerKnobs(bool randomize, ClientKnobs* clientKnobs) {
init( DD_ZERO_HEALTHY_TEAM_DELAY, 1.0 );
init( REBALANCE_MAX_RETRIES, 100 );
init( DD_OVERLAP_PENALTY, 10000 );
init( DD_VALIDATE_LOCALITY, true ); if( randomize && BUGGIFY ) DD_VALIDATE_LOCALITY = deterministicRandom()->random01() < 0.6 ? true : false;
init( DD_VALIDATE_LOCALITY, true ); if( randomize && BUGGIFY ) DD_VALIDATE_LOCALITY = false;
// TeamRemover
TR_FLAG_DISABLE_MACHINE_TEAM_REMOVER = false; if( randomize && BUGGIFY ) TR_FLAG_DISABLE_MACHINE_TEAM_REMOVER = deterministicRandom()->random01() < 0.1 ? true : false; // false by default. disable the consistency check when it's true