fix: update the encoding of AddressExclusion in SystemData #963

This commit is contained in:
Vishesh Yadav 2019-02-28 11:56:37 -08:00
parent 592e224155
commit 41d18db7b9
2 changed files with 12 additions and 5 deletions

View File

@ -1068,8 +1068,19 @@ bool GetRangeLimits::hasSatisfiedMinRows() {
AddressExclusion AddressExclusion::parse( StringRef const& key ) {
//Must not change: serialized to the database!
auto parsedIp = IPAddress::parse(key.toString());
if (parsedIp.present()) {
return AddressExclusion(parsedIp.get());
}
try {
auto addr = NetworkAddress::parse(key.toString());
if (addr.isTLS()) {
TraceEvent(SevWarnAlways, "AddressExclusionParseError")
.detail("String", printable(key))
.detail("Description", "Address inclusion string should not include `:tls' suffix.");
return AddressExclusion();
}
return AddressExclusion(addr.ip, addr.port);
} catch (Error& e) {
TraceEvent(SevWarnAlways, "AddressExclusionParseError").detail("String", printable(key));

View File

@ -374,11 +374,7 @@ const AddressExclusion decodeExcludedServersKey( KeyRef const& key ) {
}
std::string encodeExcludedServersKey( AddressExclusion const& addr ) {
//FIXME: make sure what's persisted here is not affected by innocent changes elsewhere
std::string as = format("%s", addr.ip.toString().c_str());
//ASSERT( StringRef(as).endsWith(LiteralStringRef(":0")) == (addr.port == 0) );
if (!addr.isWholeMachine())
as += format(":%d", addr.port);
return excludedServersPrefix.toString() + as;
return excludedServersPrefix.toString() + addr.toString();
}
const KeyRangeRef workerListKeys( LiteralStringRef("\xff/worker/"), LiteralStringRef("\xff/worker0") );