jstests/replsets/rollback_set_fcv.js
// toFCV refers to the FCV we will test rolling back to.
toFCV refers to the FCV we will test rolling back to.
toFCV refers to the FCV we will test rolling back to .
function rollbackFCVFromDowngradingOrUpgrading(fromFCV, toFCV) {
    let primary = rollbackTest.getPrimary();
    let secondary = rollbackTest.getSecondary();
    let primaryAdminDB = primary.getDB('admin');
    let secondaryAdminDB = secondary.getDB('admin');
    assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: toFCV}));
    rollbackTest.getTestFixture().waitForConfigReplication(primary);
    rollbackTest.getTestFixture().awaitLastOpCommitted(undefined , [secondary]);
    jsTestLog("Testing rolling back FCV from {version: " + lastLTSFCV +
              ", targetVersion: " + fromFCV + "} to {version: " + toFCV + "}");
    rollbackTest.transitionToRollbackOperations();
    let setFCVInParallel = startParallelShell(funWithArgs(setFCV, fromFCV), primary.port);
    assert.soon(function() {
        let featureCompatibilityVersion = getFCVFromDocument(primary);
        return featureCompatibilityVersion.hasOwnProperty('targetVersion');
    }, "Failed waiting for the server to set the targetVersion: " + fromFCV);
    rollbackTest.transitionToSyncSourceOperationsBeforeRollback();
    checkFCV(secondaryAdminDB, toFCV);
    rollbackTest.transitionToSyncSourceOperationsDuringRollback();
    setFCVInParallel();
    rollbackTest.transitionToSteadyStateOperations();
    checkFCV(primaryAdminDB, toFCV);
    checkFCV(secondaryAdminDB, toFCV);
    let newPrimary = rollbackTest.getPrimary();
    assert.commandWorked(newPrimary.adminCommand({setFeatureCompatibilityVersion: toFCV}));
}
function rollbackFCVFromDowngradingOrUpgrading ( fromFCV , toFCV ) { let primary = rollbackTest . getPrimary ( ) ; let secondary = rollbackTest . getSecondary ( ) ; let primaryAdminDB = primary . getDB ( 'admin' ) ; let secondaryAdminDB = secondary . getDB ( 'admin' ) ; assert . commandWorked ( primary . adminCommand ( { setFeatureCompatibilityVersion : toFCV } ) ) ; rollbackTest . getTestFixture ( ) . waitForConfigReplication ( primary ) ; rollbackTest . getTestFixture ( ) . awaitLastOpCommitted ( undefined , [ secondary ] ) ; jsTestLog ( "Testing rolling back FCV from {version: " + lastLTSFCV + ", targetVersion: " + fromFCV + "} to {version: " + toFCV + "}" ) ; rollbackTest . transitionToRollbackOperations ( ) ; let setFCVInParallel = startParallelShell ( funWithArgs ( setFCV , fromFCV ) , primary . port ) ; assert . soon ( function ( ) { let featureCompatibilityVersion = getFCVFromDocument ( primary ) ; return featureCompatibilityVersion . hasOwnProperty ( 'targetVersion' ) ; } , "Failed waiting for the server to set the targetVersion: " + fromFCV ) ; rollbackTest . transitionToSyncSourceOperationsBeforeRollback ( ) ; checkFCV ( secondaryAdminDB , toFCV ) ; rollbackTest . transitionToSyncSourceOperationsDuringRollback ( ) ; setFCVInParallel ( ) ; rollbackTest . transitionToSteadyStateOperations ( ) ; checkFCV ( primaryAdminDB , toFCV ) ; checkFCV ( secondaryAdminDB , toFCV ) ; let newPrimary = rollbackTest . getPrimary ( ) ; assert . commandWorked ( newPrimary . adminCommand ( { setFeatureCompatibilityVersion : toFCV } ) ) ; }
toFCV refers to the FCV we will test rolling back to.
toFCV refers to the FCV we will test rolling back to .
// Ensure the cluster starts at the correct FCV. // Wait until the config has propagated to the other nodes and the primary has learned of it, so // that the config replication check in 'setFeatureCompatibilityVersion' is satisfied. This is // only important since 'setFeatureCompatibilityVersion' is known to implicitly call internal // reconfigs as part of upgrade/downgrade behavior. // Wait for the majority commit point to be updated on the secondary, because checkFCV calls // getParameter for the featureCompatibilityVersion, which will wait until the FCV change makes // it into the node's majority committed snapshot. /* timeout */ // Wait for the FCV update to be reflected on the primary. This should eventually be rolled // back. // Secondaries should never have received the FCV update. // The primary should have rolled back their FCV to be consistent with the rest of the replica // set. // As a rule, we forbid downgrading a node while a node is still in the upgrading state and // vice versa. Ensure that the in-memory and on-disk FCV are consistent by checking that we are // able to set the FCV back to the original version.