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 rollbackFCVFromDowngradedOrUpgraded(fromFCV, toFCV, failPoint) {
    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().awaitLastOpCommitted(undefined , [secondary]);
    jsTestLog("Testing rolling back FCV from {version: " + fromFCV +
              "} to {version: " + lastLTSFCV + ", targetVersion: " + fromFCV + "}");
    const hangBeforeUnsettingTargetVersion = configureFailPoint(primary, failPoint);
    let setFCVInParallel = startParallelShell(funWithArgs(setFCV, fromFCV), primary.port);
    hangBeforeUnsettingTargetVersion.wait();
    rollbackTest.transitionToRollbackOperations();
    hangBeforeUnsettingTargetVersion.off();
    assert.soon(function() {
        let featureCompatibilityVersion = getFCVFromDocument(primary);
        return !featureCompatibilityVersion.hasOwnProperty('targetVersion') &&
            featureCompatibilityVersion.version === fromFCV;
    }, "Failed waiting for server to unset the targetVersion or to set the FCV to " + fromFCV);
    rollbackTest.transitionToSyncSourceOperationsBeforeRollback();
    checkFCV(secondaryAdminDB, lastLTSFCV, fromFCV);
    rollbackTest.transitionToSyncSourceOperationsDuringRollback();
    setFCVInParallel();
    rollbackTest.transitionToSteadyStateOperations();
    checkFCV(primaryAdminDB, lastLTSFCV, fromFCV);
    checkFCV(secondaryAdminDB, lastLTSFCV, fromFCV);
    let newPrimary = rollbackTest.getPrimary();
    assert.commandFailedWithCode(newPrimary.adminCommand({setFeatureCompatibilityVersion: toFCV}),
                                 5147403);
}
function rollbackFCVFromDowngradedOrUpgraded ( fromFCV , toFCV , failPoint ) { 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 ( ) . awaitLastOpCommitted ( undefined , [ secondary ] ) ; jsTestLog ( "Testing rolling back FCV from {version: " + fromFCV + "} to {version: " + lastLTSFCV + ", targetVersion: " + fromFCV + "}" ) ; const hangBeforeUnsettingTargetVersion = configureFailPoint ( primary , failPoint ) ; let setFCVInParallel = startParallelShell ( funWithArgs ( setFCV , fromFCV ) , primary . port ) ; hangBeforeUnsettingTargetVersion . wait ( ) ; rollbackTest . transitionToRollbackOperations ( ) ; hangBeforeUnsettingTargetVersion . off ( ) ; assert . soon ( function ( ) { let featureCompatibilityVersion = getFCVFromDocument ( primary ) ; return ! featureCompatibilityVersion . hasOwnProperty ( 'targetVersion' ) && featureCompatibilityVersion . version === fromFCV ; } , "Failed waiting for server to unset the targetVersion or to set the FCV to " + fromFCV ) ; rollbackTest . transitionToSyncSourceOperationsBeforeRollback ( ) ; checkFCV ( secondaryAdminDB , lastLTSFCV , fromFCV ) ; rollbackTest . transitionToSyncSourceOperationsDuringRollback ( ) ; setFCVInParallel ( ) ; rollbackTest . transitionToSteadyStateOperations ( ) ; checkFCV ( primaryAdminDB , lastLTSFCV , fromFCV ) ; checkFCV ( secondaryAdminDB , lastLTSFCV , fromFCV ) ; let newPrimary = rollbackTest . getPrimary ( ) ; assert . commandFailedWithCode ( newPrimary . adminCommand ( { setFeatureCompatibilityVersion : toFCV } ) , 5147403 ) ; }
toFCV refers to the FCV we will test rolling back to.
toFCV refers to the FCV we will test rolling back to .
// Complete the upgrade/downgrade to ensure we are not in the upgrading/downgrading state. // 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 */ // A failpoint to hang right before unsetting the targetVersion. // Turn off the failpoint so the primary will proceed to unset the targetVersion. This update // should never make it to the secondary. // The secondary should never have received the update to unset the targetVersion. // The primary should have rolled back their FCV to contain the targetVersion. // 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 this // rule is upheld after rollback.