jstests/replsets/dbcheck.js
// restart it back as a secondary.
restart it back as a secondary.
restart it back as a secondary .
function injectInconsistencyOnSecondary(cmd) {
    const secondaryConn = replSet.getSecondary();
    const secondaryNodeId = replSet.getNodeId(secondaryConn);
    replSet.stop(secondaryNodeId, {forRestart: true });
    const standaloneConn = MongoRunner.runMongod({
        dbpath: secondaryConn.dbpath,
        noCleanData: true,
    });
    const standaloneDB = standaloneConn.getDB(dbName);
    assert.commandWorked(standaloneDB.runCommand(cmd));
    MongoRunner.stopMongod(standaloneConn);
    replSet.start(secondaryNodeId, {}, true );
    replSet.awaitNodesAgreeOnPrimaryNoAuth();
}
function injectInconsistencyOnSecondary ( cmd ) { const secondaryConn = replSet . getSecondary ( ) ; const secondaryNodeId = replSet . getNodeId ( secondaryConn ) ; replSet . stop ( secondaryNodeId , { forRestart : true } ) ; const standaloneConn = MongoRunner . runMongod ( { dbpath : secondaryConn . dbpath , noCleanData : true , } ) ; const standaloneDB = standaloneConn . getDB ( dbName ) ; assert . commandWorked ( standaloneDB . runCommand ( cmd ) ) ; MongoRunner . stopMongod ( standaloneConn ) ; replSet . start ( secondaryNodeId , { } , true ) ; replSet . awaitNodesAgreeOnPrimaryNoAuth ( ) ; }
restart it back as a secondary.
restart it back as a secondary .
/* preserve dbPath */ // Shut down the secondary and restart it as a member of the replica set. /*restart*/