Make names even across change and add lowest-compatible-version to status json

This commit is contained in:
Bharadwaj V.R 2022-04-15 13:57:58 -07:00
parent ce5bcc0261
commit 11f2827c82
4 changed files with 42 additions and 23 deletions

View File

@ -695,7 +695,8 @@ const KeyRef JSONSchemas::statusSchema = LiteralStringRef(R"statusSchema(
},
"cluster_controller_timestamp":1415650089,
"protocol_version":"fdb00a400050001",
"latest_server_version":"fdb00a500040001",
"newest_protocol_version":"fdb00a500040001",
"lowest_compatible_protocol_version":"fdb00a500040001",
"connection_string":"a:a@127.0.0.1:4000",
"full_replication":true,
"maintenance_zone":"0ccb4e0fdbdb5583010f6b77d9d10ece",

View File

@ -1408,8 +1408,8 @@ ACTOR Future<Void> clusterRecoveryCore(Reference<ClusterRecoveryData> self) {
wait(self->cstate.read());
if (self->cstate.prevDBState.lowestCompatibleServerVersion > currentProtocolVersion) {
TraceEvent(SevWarnAlways, "IncompatibleServerVersion", self->dbgid).log();
if (self->cstate.prevDBState.lowestCompatibleProtocolVersion > currentProtocolVersion) {
TraceEvent(SevWarnAlways, "IncompatibleProtocolVersion", self->dbgid).log();
throw internal_error();
}
@ -1469,18 +1469,18 @@ ACTOR Future<Void> clusterRecoveryCore(Reference<ClusterRecoveryData> self) {
DBCoreState newState = self->cstate.myDBState;
newState.recoveryCount++;
newState.recoveryCount++;
if (self->cstate.prevDBState.newestServerVersion.isInvalidMagic() ||
self->cstate.prevDBState.newestServerVersion < currentProtocolVersion) {
ASSERT(self->cstate.myDBState.lowestCompatibleServerVersion.isInvalidMagic() ||
!self->cstate.myDBState.newestServerVersion.isInvalidMagic());
newState.newestServerVersion = currentProtocolVersion;
newState.lowestCompatibleServerVersion = minCompatibleProtocolVersion;
if (self->cstate.prevDBState.newestProtocolVersion.isInvalidMagic() ||
self->cstate.prevDBState.newestProtocolVersion < currentProtocolVersion) {
ASSERT(self->cstate.myDBState.lowestCompatibleProtocolVersion.isInvalidMagic() ||
!self->cstate.myDBState.newestProtocolVersion.isInvalidMagic());
newState.newestProtocolVersion = currentProtocolVersion;
newState.lowestCompatibleProtocolVersion = minCompatibleProtocolVersion;
}
wait(self->cstate.write(newState) || recoverAndEndEpoch);
TraceEvent("SWVersionCompatibilityChecked", self->dbgid)
.detail("NewestServerVersion", self->cstate.myDBState.newestServerVersion)
.detail("LowestCompatibleVersion", self->cstate.myDBState.lowestCompatibleServerVersion)
TraceEvent("ProtocolVersionCompatibilityChecked", self->dbgid)
.detail("NewestProtocolVersion", self->cstate.myDBState.newestProtocolVersion)
.detail("LowestCompatibleProtocolVersion", self->cstate.myDBState.lowestCompatibleProtocolVersion)
.trackLatest(self->swVersionCheckedEventHolder->trackingKey);
self->recoveryState = RecoveryState::RECRUITING;

View File

@ -141,13 +141,13 @@ struct DBCoreState {
DBRecoveryCount recoveryCount; // Increases with sequential successful recoveries.
LogSystemType logSystemType;
std::set<int8_t> pseudoLocalities;
ProtocolVersion newestServerVersion;
ProtocolVersion lowestCompatibleServerVersion;
ProtocolVersion newestProtocolVersion;
ProtocolVersion lowestCompatibleProtocolVersion;
DBCoreState()
: logRouterTags(0), txsTags(0), recoveryCount(0), logSystemType(LogSystemType::empty),
newestServerVersion(ProtocolVersion::invalidProtocolVersion),
lowestCompatibleServerVersion(ProtocolVersion::invalidProtocolVersion) {}
newestProtocolVersion(ProtocolVersion::invalidProtocolVersion),
lowestCompatibleProtocolVersion(ProtocolVersion::invalidProtocolVersion) {}
std::vector<UID> getPriorCommittedLogServers() {
std::vector<UID> priorCommittedLogServers;
@ -186,7 +186,7 @@ struct DBCoreState {
serializer(ar, txsTags);
}
if (ar.protocolVersion().hasSWVersionTracking()) {
serializer(ar, newestServerVersion, lowestCompatibleServerVersion);
serializer(ar, newestProtocolVersion, lowestCompatibleProtocolVersion);
}
} else if (ar.isDeserializing) {
tLogs.push_back(CoreTLogSet());

View File

@ -1528,7 +1528,20 @@ ACTOR static Future<Void> logRangeWarningFetcher(Database cx,
return Void();
}
ACTOR Future<ProtocolVersion> getNewestProtocolVersion(Database cx, WorkerDetails ccWorker) {
struct ProtocolVersionData {
ProtocolVersion runningProtocolVersion;
ProtocolVersion newestProtocolVersion;
ProtocolVersion lowestCompatibleProtocolVersion;
ProtocolVersionData()
: runningProtocolVersion(currentProtocolVersion), newestProtocolVersion(ProtocolVersion()),
lowestCompatibleProtocolVersion(ProtocolVersion()) {}
ProtocolVersionData(uint64_t newestProtocolVersionValue, uint64_t lowestCompatibleProtocolVersionValue)
: runningProtocolVersion(currentProtocolVersion), newestProtocolVersion(newestProtocolVersionValue),
lowestCompatibleProtocolVersion(lowestCompatibleProtocolVersionValue) {}
};
ACTOR Future<ProtocolVersionData> getNewestProtocolVersion(Database cx, WorkerDetails ccWorker) {
try {
state Future<TraceEventFields> swVersionF = timeoutError(
@ -1537,15 +1550,18 @@ ACTOR Future<ProtocolVersion> getNewestProtocolVersion(Database cx, WorkerDetail
wait(success(swVersionF));
const TraceEventFields& swVersionTrace = swVersionF.get();
int64_t newestProtocolVersionValue =
std::stoull(swVersionTrace.getValue("NewestServerVersion").c_str(), nullptr, 16);
return ProtocolVersion(newestProtocolVersionValue);
std::stoull(swVersionTrace.getValue("NewestProtocolVersion").c_str(), nullptr, 16);
int64_t lowestCompatibleProtocolVersionValue =
std::stoull(swVersionTrace.getValue("LowestCompatibleProtocolVersion").c_str(), nullptr, 16);
return ProtocolVersionData(newestProtocolVersionValue, lowestCompatibleProtocolVersionValue);
} catch (Error& e) {
if (e.code() == error_code_actor_cancelled)
throw;
TraceEvent(SevWarnAlways, "SWVersionStatusFailed").error(e);
return ProtocolVersion();
return ProtocolVersionData();
}
}
@ -2902,7 +2918,7 @@ ACTOR Future<StatusReply> clusterGetStatus(
messages.push_back(message);
}
state ProtocolVersion newestProtocolVersion = wait(getNewestProtocolVersion(cx, ccWorker));
state ProtocolVersionData protocolVersion = wait(getNewestProtocolVersion(cx, ccWorker));
// construct status information for cluster subsections
state int statusCode = (int)RecoveryStatus::END;
@ -2941,7 +2957,9 @@ ACTOR Future<StatusReply> clusterGetStatus(
statusObj["protocol_version"] = format("%" PRIx64, g_network->protocolVersion().version());
statusObj["connection_string"] = coordinators.ccr->getConnectionString().toString();
statusObj["bounce_impact"] = getBounceImpactInfo(statusCode);
statusObj["latest_server_version"] = format("%" PRIx64, newestProtocolVersion.version());
statusObj["newest_protocol_version"] = format("%" PRIx64, protocolVersion.newestProtocolVersion.version());
statusObj["lowest_compatible_protocol_version"] =
format("%" PRIx64, protocolVersion.lowestCompatibleProtocolVersion.version());
state Optional<DatabaseConfiguration> configuration;
state Optional<LoadConfigurationResult> loadResult;