jstests/noPassthrough/batched_multi_deletes_oplog.js
// Verifies that batches replicate as applyOps entries.
Verifies that batches replicate as applyOps entries.
Verifies that batches replicate as applyOps entries .
function validateBatchedDeletesOplogDocsPerBatch(conn) {
    const db = conn.getDB("test");
    const coll = db.getCollection("c");
    const docsPerBatch = 100;
    const collCount = 5017;  
    assert.commandWorked(db.adminCommand({setParameter: 1, batchedDeletesTargetStagedDocBytes: 0}));
    assert.commandWorked(db.adminCommand({setParameter: 1, batchedDeletesTargetBatchTimeMS: 0}));
    assert.commandWorked(
        db.adminCommand({setParameter: 1, batchedDeletesTargetBatchDocs: docsPerBatch}));
    coll.drop();
    assert.commandWorked(
        coll.insertMany([...Array(collCount).keys()].map(x => ({_id: x, a: "a".repeat(1024)}))));
    assert.eq(collCount, coll.find().itcount());
    assert.commandWorked(coll.deleteMany({_id: {$gte: 0}}));
    assert.eq(0, coll.find().itcount());
    const applyOpsEntriesFull =
        db.getSiblingDB('local').oplog.rs.find({'o.applyOps': {$size: docsPerBatch}}).itcount();
    const applyOpsEntriesLast =
        db.getSiblingDB('local')
            .oplog.rs.find({'o.applyOps': {$size: collCount % docsPerBatch}})
            .itcount();
    const expectedApplyOpsEntries = Math.ceil(collCount / docsPerBatch);
    assert.eq(applyOpsEntriesFull + applyOpsEntriesLast, expectedApplyOpsEntries);
}
function validateBatchedDeletesOplogDocsPerBatch ( conn ) { const db = conn . getDB ( "test" ) ; const coll = db . getCollection ( "c" ) ; const docsPerBatch = 100 ; const collCount = 5017 ; assert . commandWorked ( db . adminCommand ( { setParameter : 1 , batchedDeletesTargetStagedDocBytes : 0 } ) ) ; assert . commandWorked ( db . adminCommand ( { setParameter : 1 , batchedDeletesTargetBatchTimeMS : 0 } ) ) ; assert . commandWorked ( db . adminCommand ( { setParameter : 1 , batchedDeletesTargetBatchDocs : docsPerBatch } ) ) ; coll . drop ( ) ; assert . commandWorked ( coll . insertMany ( [ ... Array ( collCount ) . keys ( ) ] . map ( x => ( { _id : x , a : "a" . repeat ( 1024 ) } ) ) ) ) ; assert . eq ( collCount , coll . find ( ) . itcount ( ) ) ; assert . commandWorked ( coll . deleteMany ( { _id : { $gte : 0 } } ) ) ; assert . eq ( 0 , coll . find ( ) . itcount ( ) ) ; const applyOpsEntriesFull = db . getSiblingDB ( 'local' ) . oplog . rs . find ( { 'o.applyOps' : { $size : docsPerBatch } } ) . itcount ( ) ; const applyOpsEntriesLast = db . getSiblingDB ( 'local' ) . oplog . rs . find ( { 'o.applyOps' : { $size : collCount % docsPerBatch } } ) . itcount ( ) ; const expectedApplyOpsEntries = Math . ceil ( collCount / docsPerBatch ) ; assert . eq ( applyOpsEntriesFull + applyOpsEntriesLast , expectedApplyOpsEntries ) ; }
Verifies that batches replicate as applyOps entries.
Verifies that batches replicate as applyOps entries .
// Intentionally not a multiple of docsPerBatch. // Disable size-based batching // Disable time-based batching // Set docs per batch target // The deletion replicates as one applyOps per batch