Use IPAddress instead of NetworkAddress for exclude

NetworkAddress has other fields like flags that aren't relevant for
exclude. Network addresses with equal ip addresses not comparing equal
appears to be the cause of #3565
This commit is contained in:
Andrew Noyes 2020-07-27 05:40:14 +00:00
parent 9d3b1cc4e4
commit 331ee4dab4
3 changed files with 12 additions and 13 deletions

View File

@ -2295,7 +2295,7 @@ ACTOR Future<bool> exclude( Database db, std::vector<StringRef> tokens, Referenc
if(warn.isValid())
warn.cancel();
state std::set<NetworkAddress> notExcludedServers =
state std::set<IPAddress> notExcludedServers =
wait(makeInterruptable(checkForExcludingServers(db, addresses, waitForAllExcluded)));
std::vector<ProcessData> workers = wait( makeInterruptable(getWorkers(db)) );
std::map<IPAddress, std::set<uint16_t>> workerPorts;
@ -2312,8 +2312,7 @@ ACTOR Future<bool> exclude( Database db, std::vector<StringRef> tokens, Referenc
absentExclusions.insert(addr);
}
for (auto addr : addresses) {
NetworkAddress _addr(addr.ip, addr.port);
for (const auto& addr : addresses) {
if (absentExclusions.find(addr) != absentExclusions.end()) {
if(addr.port == 0)
printf(" %s(Whole machine) ---- WARNING: Missing from cluster!Be sure that you excluded the "
@ -2323,7 +2322,7 @@ ACTOR Future<bool> exclude( Database db, std::vector<StringRef> tokens, Referenc
printf(" %s ---- WARNING: Missing from cluster! Be sure that you excluded the correct processes "
"before removing them from the cluster!\n",
addr.toString().c_str());
} else if (notExcludedServers.find(_addr) != notExcludedServers.end()) {
} else if (notExcludedServers.find(addr.ip) != notExcludedServers.end()) {
if (addr.port == 0)
printf(" %s(Whole machine) ---- WARNING: Exclusion in progress! It is not safe to remove this "
"machine from the cluster\n",

View File

@ -1548,10 +1548,10 @@ ACTOR Future<int> setDDMode( Database cx, int mode ) {
}
}
ACTOR Future<std::set<NetworkAddress>> checkForExcludingServers(Database cx, vector<AddressExclusion> excl,
bool waitForAllExcluded) {
ACTOR Future<std::set<IPAddress>> checkForExcludingServers(Database cx, vector<AddressExclusion> excl,
bool waitForAllExcluded) {
state std::set<AddressExclusion> exclusions( excl.begin(), excl.end() );
state std::set<NetworkAddress> inProgressExclusion;
state std::set<IPAddress> inProgressExclusion;
if (!excl.size()) return inProgressExclusion;
@ -1575,11 +1575,11 @@ ACTOR Future<std::set<NetworkAddress>> checkForExcludingServers(Database cx, vec
auto addresses = decodeServerListValue( s.value ).getKeyValues.getEndpoint().addresses;
if ( addressExcluded(exclusions, addresses.address) ) {
ok = false;
inProgressExclusion.insert(addresses.address);
inProgressExclusion.insert(addresses.address.ip);
}
if ( addresses.secondaryAddress.present() && addressExcluded(exclusions, addresses.secondaryAddress.get()) ) {
ok = false;
inProgressExclusion.insert(addresses.secondaryAddress.get());
inProgressExclusion.insert(addresses.secondaryAddress.get().ip);
}
}
@ -1590,13 +1590,13 @@ ACTOR Future<std::set<NetworkAddress>> checkForExcludingServers(Database cx, vec
for( auto const& log : logs.first ) {
if (log.second == NetworkAddress() || addressExcluded(exclusions, log.second)) {
ok = false;
inProgressExclusion.insert(log.second);
inProgressExclusion.insert(log.second.ip);
}
}
for( auto const& log : logs.second ) {
if (log.second == NetworkAddress() || addressExcluded(exclusions, log.second)) {
ok = false;
inProgressExclusion.insert(log.second);
inProgressExclusion.insert(log.second.ip);
}
}
}

View File

@ -158,8 +158,8 @@ ACTOR Future<vector<AddressExclusion>> getExcludedServers( Database cx );
// Check for the given, previously excluded servers to be evacuated (no longer used for state). If waitForExclusion is
// true, this actor returns once it is safe to shut down all such machines without impacting fault tolerance, until and
// unless any of them are explicitly included with includeServers()
ACTOR Future<std::set<NetworkAddress>> checkForExcludingServers(Database cx, vector<AddressExclusion> servers,
bool waitForAllExcluded);
ACTOR Future<std::set<IPAddress>> checkForExcludingServers(Database cx, vector<AddressExclusion> servers,
bool waitForAllExcluded);
// Gets a list of all workers in the cluster (excluding testers)
ACTOR Future<vector<ProcessData>> getWorkers( Database cx );