diff options
4 files changed, 31 insertions, 27 deletions
diff --git a/jstests/multiVersion/genericSetFCVUsage/set_feature_compatibility_version.js b/jstests/multiVersion/genericSetFCVUsage/set_feature_compatibility_version.js index 2ddd0a4d869..c2b98d86c62 100644 --- a/jstests/multiVersion/genericSetFCVUsage/set_feature_compatibility_version.js +++ b/jstests/multiVersion/genericSetFCVUsage/set_feature_compatibility_version.js @@ -560,24 +560,6 @@ function runShardingTest(downgradeVersion) { downgradedShard.stopSet(); } -// TODO SERVER-53894: Remove to re-enable test for feature flag enabled variants. -jsTestLog( - "Running standalone to gather parameter info about featureFlag: featureFlagUseSecondaryDelaySecs"); -// Spin up a standalone to check the release version of 'featureFlagUseSecondaryDelaySecs'. -const standalone = MongoRunner.runMongod(); -const adminDB = standalone.getDB("admin"); -try { - res = assert.commandWorked( - adminDB.runCommand({getParameter: 1, featureFlagUseSecondaryDelaySecs: 1}), - "Failed to call getParameter on feature flag: featureFlagUseSecondaryDelaySecs"); -} finally { - MongoRunner.stopMongod(standalone); -} -if (res && res.featureFlagUseSecondaryDelaySecs.value) { - jsTestLog("Skipping test because the useSecondaryDelaySecs feature flag is enabled"); - return; -} - runStandaloneTest('last-lts'); runReplicaSetTest('last-lts'); runShardingTest('last-lts'); diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index 2118149fd5f..4f89b96e307 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -259,8 +259,13 @@ void FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument( OperationContext* opCtx, ServerGlobalParams::FeatureCompatibility::Version fromVersion, ServerGlobalParams::FeatureCompatibility::Version newVersion, - bool isFromConfigServer) { - auto transitioningVersion = fromVersion == newVersion + bool isFromConfigServer, + bool setTargetVersion) { + + // Only transition to fully upgraded or downgraded states when we + // have completed all required upgrade/downgrade behavior. + auto transitioningVersion = setTargetVersion && + serverGlobalParams.featureCompatibility.isUpgradingOrDowngrading(fromVersion) ? fromVersion : fcvTransitions.getTransitionalVersion(fromVersion, newVersion, isFromConfigServer); FeatureCompatibilityVersionDocument fcvDoc = diff --git a/src/mongo/db/commands/feature_compatibility_version.h b/src/mongo/db/commands/feature_compatibility_version.h index 16b879ca932..8c4af173521 100644 --- a/src/mongo/db/commands/feature_compatibility_version.h +++ b/src/mongo/db/commands/feature_compatibility_version.h @@ -84,7 +84,8 @@ public: OperationContext* opCtx, ServerGlobalParams::FeatureCompatibility::Version fromVersion, ServerGlobalParams::FeatureCompatibility::Version newVersion, - bool isFromConfigServer); + bool isFromConfigServer, + bool setTargetVersion); /** * If there are no non-local databases, store the featureCompatibilityVersion document. If we diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp index cbb1a42b858..70a3c038e3f 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -247,8 +247,14 @@ public: if (actualVersion < requestedVersion) { checkInitialSyncFinished(opCtx); + // Start transition to 'requestedVersion' by updating the local FCV document to a + // 'kUpgrading' state. FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument( - opCtx, actualVersion, requestedVersion, isFromConfigServer); + opCtx, + actualVersion, + requestedVersion, + isFromConfigServer, + true /* setTargetVersion */); // If the 'useSecondaryDelaySecs' feature flag is enabled in the upgraded FCV, issue a // reconfig to change the 'slaveDelay' field to 'secondaryDelaySecs'. @@ -330,12 +336,14 @@ public: } hangWhileUpgrading.pauseWhileSet(opCtx); - // Completed transition to requestedVersion. + // Complete transition by updating the local FCV document to the fully upgraded + // requestedVersion. FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument( opCtx, serverGlobalParams.featureCompatibility.getVersion(), requestedVersion, - isFromConfigServer); + isFromConfigServer, + false /* setTargetVersion */); } else { // Time-series collections are only supported in 5.0. If the user tries to downgrade the // cluster to an earlier version, they must first remove all time-series collections. @@ -357,8 +365,14 @@ public: checkInitialSyncFinished(opCtx); + // Start transition to 'requestedVersion' by updating the local FCV document to a + // 'kDowngrading' state. FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument( - opCtx, actualVersion, requestedVersion, isFromConfigServer); + opCtx, + actualVersion, + requestedVersion, + isFromConfigServer, + true /* setTargetVersion */); // If the 'useSecondaryDelaySecs' feature flag is disabled in the downgraded FCV, issue // a reconfig to change the 'secondaryDelaySecs' field to 'slaveDelay'. @@ -441,12 +455,14 @@ public: } hangWhileDowngrading.pauseWhileSet(opCtx); - // Completed transition to requestedVersion. + // Complete transition by updating the local FCV document to the fully downgraded + // requestedVersion. FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument( opCtx, serverGlobalParams.featureCompatibility.getVersion(), requestedVersion, - isFromConfigServer); + isFromConfigServer, + false /* setTargetVersion */); if (request.getDowngradeOnDiskChanges()) { invariant(requestedVersion == FeatureCompatibilityParams::kLastContinuous); |