jstests/noPassthrough/clustered_collection_capped_concurrency.js
// on a clustered capped collection are not serialized.
on a clustered capped collection are not serialized.
on a clustered capped collection are not serialized .
function validateCappedInsertConcurrency(db, coll, clustered, expectedConcurrent) {
    assertDropCollection(db, coll.getName());
    if (clustered) {
        assert.commandWorked(db.createCollection(coll.getName(), {
            clusteredIndex: {key: {_id: 1}, unique: true},
            capped: true,
            expireAfterSeconds: 24 * 60 * 60
        }));
    } else {
        assert.commandWorked(db.createCollection(coll.getName(), {capped: true, size: 100000000}));
    }
    const ns = coll.getFullName();
    const failPointName = "hangAfterCollectionInserts";
    const fp = assert.commandWorked(db.adminCommand(
        {configureFailPoint: failPointName, mode: "alwaysOn", data: {collectionNS: ns}}));
    const timesEntered = fp.count;
    const waitForParallelShellToShutDown = startParallelShell(
        funWithArgs(function(dbName, collName) {
            assert.commandWorked(db.getSiblingDB(dbName)[collName].insertOne({}));
        }, db.getName(), coll.getName()), replSet.getPrimary().port);
    assert.commandWorked(db.adminCommand({
        waitForFailPoint: failPointName,
        timesEntered: timesEntered + 1,
        maxTimeMS: kDefaultWaitForFailPointTimeout
    }));
    assert.eq(1, db.currentOp({ns: ns, "op": "insert"}).inprog.length);
    if (expectedConcurrent) {
        assert.eq(db.currentOp({ns: ns, "op": "insert"}).inprog[0].lockStats.Metadata, undefined);
    } else {
        assert.neq(
            db.currentOp({ns: ns, "op": "insert"}).inprog[0].lockStats.Metadata.acquireCount.W,
            undefined);
    }
    assert.commandWorked(db.adminCommand({configureFailPoint: failPointName, mode: "off"}));
    waitForParallelShellToShutDown();
    assertDropCollection(db, coll.getName());
}
function validateCappedInsertConcurrency ( db , coll , clustered , expectedConcurrent ) { assertDropCollection ( db , coll . getName ( ) ) ; if ( clustered ) { assert . commandWorked ( db . createCollection ( coll . getName ( ) , { clusteredIndex : { key : { _id : 1 } , unique : true } , capped : true , expireAfterSeconds : 24 * 60 * 60 } ) ) ; } else { assert . commandWorked ( db . createCollection ( coll . getName ( ) , { capped : true , size : 100000000 } ) ) ; } const ns = coll . getFullName ( ) ; const failPointName = "hangAfterCollectionInserts" ; const fp = assert . commandWorked ( db . adminCommand ( { configureFailPoint : failPointName , mode : "alwaysOn" , data : { collectionNS : ns } } ) ) ; const timesEntered = fp . count ; const waitForParallelShellToShutDown = startParallelShell ( funWithArgs ( function ( dbName , collName ) { assert . commandWorked ( db . getSiblingDB ( dbName ) [ collName ] . insertOne ( { } ) ) ; } , db . getName ( ) , coll . getName ( ) ) , replSet . getPrimary ( ) . port ) ; assert . commandWorked ( db . adminCommand ( { waitForFailPoint : failPointName , timesEntered : timesEntered + 1 , maxTimeMS : kDefaultWaitForFailPointTimeout } ) ) ; assert . eq ( 1 , db . currentOp ( { ns : ns , "op" : "insert" } ) . inprog . length ) ; if ( expectedConcurrent ) { assert . eq ( db . currentOp ( { ns : ns , "op" : "insert" } ) . inprog [ 0 ] . lockStats . Metadata , undefined ) ; } else { assert . neq ( db . currentOp ( { ns : ns , "op" : "insert" } ) . inprog [ 0 ] . lockStats . Metadata . acquireCount . W , undefined ) ; } assert . commandWorked ( db . adminCommand ( { configureFailPoint : failPointName , mode : "off" } ) ) ; waitForParallelShellToShutDown ( ) ; assertDropCollection ( db , coll . getName ( ) ) ; }
on a clustered capped collection are not serialized.
on a clustered capped collection are not serialized .
// There's one and only one in-flight insert to the namespace. // Assert the insert is not serialized - no Metadata resource acquisition. // Assert the insert is serialized - it acquires the Metadata resource in strong exclusive // mode.