From 11f2827c8234eff1ca71847501add1b352c65bcd Mon Sep 17 00:00:00 2001 From: "Bharadwaj V.R" Date: Fri, 15 Apr 2022 13:57:58 -0700 Subject: [PATCH] Make names even across change and add lowest-compatible-version to status json --- fdbclient/Schemas.cpp | 3 ++- fdbserver/ClusterRecovery.actor.cpp | 22 ++++++++++----------- fdbserver/DBCoreState.h | 10 +++++----- fdbserver/Status.actor.cpp | 30 +++++++++++++++++++++++------ 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/fdbclient/Schemas.cpp b/fdbclient/Schemas.cpp index 3f9dc7d518..81cbb9c073 100644 --- a/fdbclient/Schemas.cpp +++ b/fdbclient/Schemas.cpp @@ -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", diff --git a/fdbserver/ClusterRecovery.actor.cpp b/fdbserver/ClusterRecovery.actor.cpp index e62ee0b060..d92ca2fe5a 100644 --- a/fdbserver/ClusterRecovery.actor.cpp +++ b/fdbserver/ClusterRecovery.actor.cpp @@ -1408,8 +1408,8 @@ ACTOR Future clusterRecoveryCore(Reference 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 clusterRecoveryCore(Reference 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; diff --git a/fdbserver/DBCoreState.h b/fdbserver/DBCoreState.h index 9fdfd910f0..0bb6e8936e 100644 --- a/fdbserver/DBCoreState.h +++ b/fdbserver/DBCoreState.h @@ -141,13 +141,13 @@ struct DBCoreState { DBRecoveryCount recoveryCount; // Increases with sequential successful recoveries. LogSystemType logSystemType; std::set 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 getPriorCommittedLogServers() { std::vector 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()); diff --git a/fdbserver/Status.actor.cpp b/fdbserver/Status.actor.cpp index d0d2334aac..29f7a55799 100644 --- a/fdbserver/Status.actor.cpp +++ b/fdbserver/Status.actor.cpp @@ -1528,7 +1528,20 @@ ACTOR static Future logRangeWarningFetcher(Database cx, return Void(); } -ACTOR Future 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 getNewestProtocolVersion(Database cx, WorkerDetails ccWorker) { try { state Future swVersionF = timeoutError( @@ -1537,15 +1550,18 @@ ACTOR Future 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 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 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 configuration; state Optional loadResult;