diff options
author | Shin Yee Tan <shinyee.tan@mongodb.com> | 2022-11-01 20:34:23 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-01 21:30:25 +0000 |
commit | e75a51a7dcbe842e07a24343438706d865de96dc (patch) | |
tree | 9c594741783b5d14035486b9803d8caca3e122ee /jstests/noPassthrough/batched_multi_deletes_single_oplog.js | |
parent | 464abab59fa63b45d187a4145dceec3281bbcf0d (diff) | |
download | mongo-e75a51a7dcbe842e07a24343438706d865de96dc.tar.gz |
SERVER-70544 Only group oplog entries if more than one delete in batch
Diffstat (limited to 'jstests/noPassthrough/batched_multi_deletes_single_oplog.js')
-rw-r--r-- | jstests/noPassthrough/batched_multi_deletes_single_oplog.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/jstests/noPassthrough/batched_multi_deletes_single_oplog.js b/jstests/noPassthrough/batched_multi_deletes_single_oplog.js new file mode 100644 index 00000000000..cffd250ffbb --- /dev/null +++ b/jstests/noPassthrough/batched_multi_deletes_single_oplog.js @@ -0,0 +1,46 @@ +/** + * Tests that batch deletes resulting with single operations create regular delete oplog entries. + * + * @tags: [ + * requires_replication, + * ] + */ +(function() { +'use strict'; + +const dbName = jsTestName(); +const collName = "test"; +const collCount = 10; + +const rst = new ReplSetTest({nodes: 1}); +rst.startSet(); +rst.initiate(); + +const primary = rst.getPrimary(); +const db = primary.getDB(dbName); +const coll = db.getCollection(collName); +coll.drop(); + +assert.commandWorked(coll.insertMany([...Array(collCount).keys()].map(x => ({_id: x, a: x})))); +assert.eq(collCount, coll.countDocuments({})); + +// Verify the delete will involve the BATCHED_DELETE stage. +const expl = db.runCommand({ + explain: {delete: coll.getName(), deletes: [{q: {_id: {$lte: 0}}, limit: 0}]}, + verbosity: "executionStats" +}); +assert.commandWorked(expl); +assert.eq(expl["queryPlanner"]["winningPlan"]["stage"], "BATCHED_DELETE"); + +jsTestLog("Deleting all documents where _id <= 0"); +assert.commandWorked(coll.deleteMany({_id: {$lte: 0}})); + +let ops = + rst.findOplog(primary, {op: 'c', ns: 'admin.$cmd', 'o.applyOps': {$exists: true}}).toArray(); +assert.eq(0, ops.length, "Should not have an applyOps oplog entry: " + tojson(ops)); + +ops = rst.findOplog(primary, {op: 'd', ns: coll.getFullName(), o: {_id: 0}}).toArray(); +assert.eq(1, ops.length, "Should have a delete oplog entry: " + tojson(ops)); + +rst.stopSet(); +})(); |