jstests/replsets/dbcheck.js
// Just add an extra document, and test that it catches it.
Just add an extra document, and test that it catches it.
Just add an extra document and test that it catches it .
function simpleTestCatchesExtra() {
    {
        const primary = replSet.getPrimary();
        const db = primary.getDB(dbName);
        db[collName].drop();
        clearLog();
        db.createCollection(collName, {validationLevel: "off"});
    }
    replSet.awaitReplication();
    injectInconsistencyOnSecondary({insert: collName, documents: [{}]});
    replSet.awaitReplication();
    {
        const primary = replSet.getPrimary();
        const db = primary.getDB(dbName);
        assert.commandWorked(db.runCommand({dbCheck: collName}));
        awaitDbCheckCompletion(db, collName);
    }
    assert.soon(function() {
        return (replSet.getSecondary()
                    .getDB("local")
                    .system.healthlog.find({"operation": "dbCheckStop"})
                    .itcount() === 1);
    }, "dbCheck didn't complete on secondary");
    const errors = replSet.getSecondary().getDB("local").system.healthlog.find(
        {operation: /dbCheck.*/, severity: "error"});
    assert.eq(errors.count(),
              1,
              "expected exactly 1 inconsistency after single inconsistent insertion, found: " +
                  JSON.stringify(errors.toArray()));
}
function simpleTestCatchesExtra ( ) { { const primary = replSet . getPrimary ( ) ; const db = primary . getDB ( dbName ) ; db [ collName ] . drop ( ) ; clearLog ( ) ; db . createCollection ( collName , { validationLevel : "off" } ) ; } replSet . awaitReplication ( ) ; injectInconsistencyOnSecondary ( { insert : collName , documents : [ { } ] } ) ; replSet . awaitReplication ( ) ; { const primary = replSet . getPrimary ( ) ; const db = primary . getDB ( dbName ) ; assert . commandWorked ( db . runCommand ( { dbCheck : collName } ) ) ; awaitDbCheckCompletion ( db , collName ) ; } assert . soon ( function ( ) { return ( replSet . getSecondary ( ) . getDB ( "local" ) . system . healthlog . find ( { "operation" : "dbCheckStop" } ) . itcount ( ) === 1 ) ; } , "dbCheck didn't complete on secondary" ) ; const errors = replSet . getSecondary ( ) . getDB ( "local" ) . system . healthlog . find ( { operation : / dbCheck.* / , severity : "error" } ) ; assert . eq ( errors . count ( ) , 1 , "expected exactly 1 inconsistency after single inconsistent insertion, found: " + JSON . stringify ( errors . toArray ( ) ) ) ; }
Just add an extra document, and test that it catches it.
Just add an extra document and test that it catches it .
// Create the collection on the primary.