diff options
author | Adityavardhan Agrawal <aa729@cornell.edu> | 2022-11-10 21:14:48 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-10 22:27:34 +0000 |
commit | 0c82c0cfa3525721cf2269271b6978df85882bf8 (patch) | |
tree | b38a52882c6294d318762325979e2e2c6dd27b52 /jstests | |
parent | f32fceffb99d547f978528c17a1a4c0069a3c298 (diff) | |
download | mongo-0c82c0cfa3525721cf2269271b6978df85882bf8.tar.gz |
SERVER-33182 Remove atomic applyOps
Diffstat (limited to 'jstests')
31 files changed, 156 insertions, 453 deletions
diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js index ee88e552585..623940f1f85 100644 --- a/jstests/auth/lib/commands_lib.js +++ b/jstests/auth/lib/commands_lib.js @@ -887,85 +887,6 @@ var authCommandsLib = { ] }, { - testname: "applyOps_insert_UUID_with_wrong_ns", - command: function(state) { - return { - applyOps: [{ - "op": "i", - "ns": - firstDbName + ".y", // Specify wrong name but correct uuid. Should work. - "ui": state.x_uuid, // The insert should on x - "o": {"_id": ObjectId("57dc3d7da4fce4358afa85b8"), "data": 5} - }] - }; - }, - skipSharded: true, - setup: function(db) { - db.getSiblingDB(firstDbName).x.drop(); - db.getSiblingDB(firstDbName).y.drop(); - var sibling = db.getSiblingDB(firstDbName); - assert.commandWorked(sibling.runCommand({create: "x"})); - assert.commandWorked(sibling.runCommand({create: "y"})); - return {x_uuid: getUUIDFromListCollections(sibling, sibling.x.getName())}; - }, - teardown: function(db) { - db.getSiblingDB(firstDbName).x.drop(); - }, - testcases: [ - { - runOnDb: adminDbName, - privileges: [ - { - resource: {db: firstDbName, collection: "x"}, - actions: ["createCollection", "insert"] - }, - {resource: {db: firstDbName, collection: "y"}, actions: ["createCollection"]}, - {resource: {cluster: true}, actions: ["useUUID", "forceUUID", "applyOps"]}, - ], - }, - ] - }, - { - testname: "applyOps_insert_UUID_with_wrong_ns_failure", - command: function(state) { - return { - applyOps: [{ - "op": "i", - "ns": - firstDbName + ".y", // Specify wrong name but correct uuid. Should work. - "ui": state.x_uuid, // The insert should on x - "o": {"_id": ObjectId("57dc3d7da4fce4358afa85b8"), "data": 5} - }] - }; - }, - skipSharded: true, - setup: function(db) { - db.getSiblingDB(firstDbName).x.drop(); - db.getSiblingDB(firstDbName).y.drop(); - var sibling = db.getSiblingDB(firstDbName); - assert.commandWorked(sibling.runCommand({create: "x"})); - assert.commandWorked(sibling.runCommand({create: "y"})); - return {x_uuid: getUUIDFromListCollections(sibling, sibling.x.getName())}; - }, - teardown: function(db) { - db.getSiblingDB(firstDbName).x.drop(); - }, - testcases: [ - { - expectAuthzFailure: true, - runOnDb: adminDbName, - privileges: [ - {resource: {db: firstDbName, collection: "x"}, actions: ["createCollection"]}, - { - resource: {db: firstDbName, collection: "y"}, - actions: ["createCollection", "insert"] - }, - {resource: {cluster: true}, actions: ["useUUID", "forceUUID", "applyOps"]}, - ], - }, - ] - }, - { testname: "applyOps_upsert", command: { applyOps: [{ diff --git a/jstests/change_streams/apply_ops.js b/jstests/change_streams/apply_ops.js index 6d599555d2b..2ca1ced0386 100644 --- a/jstests/change_streams/apply_ops.js +++ b/jstests/change_streams/apply_ops.js @@ -2,7 +2,7 @@ * Tests that a change stream will correctly unwind applyOps entries generated by a transaction. * @tags: [ * uses_transactions, - * requires_fcv_61, # Pre-6.1 builds do not emit change stream events for atomic applyOps. + * requires_fcv_61, # Pre-6.1 builds do not emit change stream events for applyOps. * requires_majority_read_concern, * requires_snapshot_read, * ] @@ -85,7 +85,7 @@ withTxnAndAutoRetryOnMongos(session, () => { if (!FixtureHelpers.isMongos(db)) { assert.commandWorked(db.runCommand({ applyOps: [ - {op: "i", ns: coll.getFullName(), o: {_id: 3, a: "insert from atomic applyOps"}}, + {op: "i", ns: coll.getFullName(), o: {_id: 3, a: "insert from applyOps"}}, ] })); } @@ -131,7 +131,7 @@ let expectedChanges = [ if (!FixtureHelpers.isMongos(db)) { expectedChanges.push({ documentKey: {_id: 3}, - fullDocument: {_id: 3, a: "insert from atomic applyOps"}, + fullDocument: {_id: 3, a: "insert from applyOps"}, ns: {db: db.getName(), coll: coll.getName()}, operationType: "insert", }); diff --git a/jstests/change_streams/lookup_pit_pre_and_post_image_in_transaction.js b/jstests/change_streams/lookup_pit_pre_and_post_image_in_transaction.js index 0db693f55ba..7c5b274cd41 100644 --- a/jstests/change_streams/lookup_pit_pre_and_post_image_in_transaction.js +++ b/jstests/change_streams/lookup_pit_pre_and_post_image_in_transaction.js @@ -1,8 +1,8 @@ /** * Tests that point-in-time pre- and post-images are retrieved for update/replace/delete operations - * performed in a transaction and non-atomic "applyOps" command. + * performed in a transaction and "applyOps" command. * @tags: [ - * requires_fcv_60, + * requires_fcv_62, * uses_transactions, * ] */ @@ -130,14 +130,13 @@ assertChangeEventsReturned(changeStreamCursor, [ // "applyOps" command can only be issued on a replica set. if (!FixtureHelpers.isMongos(testDB)) { - jsTestLog("Testing non-atomic 'applyOps' command."); + jsTestLog("Testing 'applyOps' command."); assert.commandWorked(coll.insert([{_id: 5, a: 1}, {_id: 6, a: 1}])); assert.commandWorked(testDB.runCommand({ applyOps: [ {op: "u", ns: coll.getFullName(), o2: {_id: 5}, o: {$v: 2, diff: {u: {a: 2}}}}, {op: "d", ns: coll.getFullName(), o: {_id: 6}} - ], - allowAtomic: false, + ] })); assertChangeEventsReturned(changeStreamCursor, [ {_id: 5, operationType: "insert", postImage: {_id: 5, a: 1}}, diff --git a/jstests/concurrency/fsm_workloads/view_catalog_direct_system_writes.js b/jstests/concurrency/fsm_workloads/view_catalog_direct_system_writes.js index 221a0b9c828..6531268d2ed 100644 --- a/jstests/concurrency/fsm_workloads/view_catalog_direct_system_writes.js +++ b/jstests/concurrency/fsm_workloads/view_catalog_direct_system_writes.js @@ -16,8 +16,6 @@ var $config = extendWorkload($config, function($config, $super) { let pipeline = [{$match: {_id: this.counter}}]; assertAlways.commandWorkedOrFailedWithCode(db.createCollection("system.views"), ErrorCodes.NamespaceExists); - // Runs applyOps as non-atomic to avoid 3 way deadlock between applyOps cmd, prepared - // transaction and secondary oplog fetcher initiated find command. assertAlways.commandWorked(db.adminCommand({ applyOps: [{ op: "i", @@ -27,22 +25,18 @@ var $config = extendWorkload($config, function($config, $super) { viewOn: this.threadCollName, pipeline: pipeline } - }], - allowAtomic: false + }] })); this.confirmViewDefinition(db, this.threadViewName, collName, pipeline, this.counter); }; $config.states.drop = function drop(db, collName) { - // Runs applyOps as non-atomic to avoid 3 way deadlock between applyOps cmd, prepared - // transaction and secondary oplog fetcher initiated find command. assertAlways.commandWorked(db.adminCommand({ applyOps: [{ op: "d", ns: db.getName() + ".system.views", o: {_id: db.getName() + "." + this.threadViewName} - }], - allowAtomic: false + }] })); let res = db.runCommand({listCollections: 1, filter: {name: this.threadViewName}}); diff --git a/jstests/core/apply_ops1.js b/jstests/core/apply_ops1.js index 8eaac933184..7c54e843e1f 100644 --- a/jstests/core/apply_ops1.js +++ b/jstests/core/apply_ops1.js @@ -204,8 +204,7 @@ assert.eq(0, t.find().count(), "Non-zero amount of documents in collection to st /** * Test function for running CRUD operations on non-existent namespaces using various - * combinations of invalid namespaces (collection/database), allowAtomic and alwaysUpsert, - * and nesting. + * combinations of invalid namespaces (collection/database), alwaysUpsert, and nesting. * * Leave 'expectedErrorCode' undefined if this command is expected to run successfully. */ @@ -216,20 +215,14 @@ function testCrudOperationOnNonExistentNamespace(optype, o, o2, expectedErrorCod const op = {op: optype, ns: coll.getFullName(), o: o, o2: o2}; [false, true].forEach(nested => { const opToRun = nested ? {op: 'c', ns: 'test.$cmd', o: {applyOps: [op]}, o2: {}} : op; - [false, true].forEach(allowAtomic => { - [false, true].forEach(alwaysUpsert => { - const cmd = { - applyOps: [opToRun], - allowAtomic: allowAtomic, - alwaysUpsert: alwaysUpsert - }; - jsTestLog('Testing applyOps on non-existent namespace: ' + tojson(cmd)); - if (expectedErrorCode === ErrorCodes.OK) { - assert.commandWorked(db.adminCommand(cmd)); - } else { - assert.commandFailedWithCode(db.adminCommand(cmd), expectedErrorCode); - } - }); + [false, true].forEach(alwaysUpsert => { + const cmd = {applyOps: [opToRun], alwaysUpsert: alwaysUpsert}; + jsTestLog('Testing applyOps on non-existent namespace: ' + tojson(cmd)); + if (expectedErrorCode === ErrorCodes.OK) { + assert.commandWorked(db.adminCommand(cmd)); + } else { + assert.commandFailedWithCode(db.adminCommand(cmd), expectedErrorCode); + } }); }); }); @@ -304,14 +297,13 @@ assert.commandFailedWithCode(db.runCommand({ preCondition: [] }), 6711600); -// Expect the same error code when 'allowAtomic' is false, or with operations that include commands. +// Expect the same error code with operations that include commands. assert.commandFailedWithCode(db.runCommand({ applyOps: [ {op: "u", ns: t.getFullName(), o2: {_id: 5}, o: {$v: 2, diff: {u: {x: 20}}}}, {op: "u", ns: t.getFullName(), o2: {_id: 5}, o: {$v: 2, diff: {u: {x: 21}}}} ], - preCondition: [{ns: t.getFullName(), q: {_id: 5}, res: {x: 19}}], - allowAtomic: false + preCondition: [{ns: t.getFullName(), q: {_id: 5}, res: {x: 19}}] }), 6711600); // The use of preCondition is also incompatible with operations that include commands. diff --git a/jstests/core/apply_ops2.js b/jstests/core/apply_ops2.js index 486d60aac1d..976a41cd197 100644 --- a/jstests/core/apply_ops2.js +++ b/jstests/core/apply_ops2.js @@ -4,6 +4,8 @@ * @tags: [ * requires_non_retryable_commands, * requires_fastcount, + * # 6.2 removes support for atomic applyOps + * requires_fcv_62, * # applyOps is not supported on mongos * assumes_against_mongod_not_mongos, * # applyOps uses the oplog that require replication support @@ -68,8 +70,7 @@ res = db.runCommand({ alwaysUpsert: false }); -// Because the CRUD apply-ops are atomic, all results are false, even the first one. -assert.eq(false, res.results[0], "upsert = false, existing doc update failed"); +assert.eq(true, res.results[0], "upsert = true, existing doc expected to succeed, but it failed"); assert.eq(false, res.results[1], "upsert = false, nonexisting doc upserted"); assert.eq(2, t.find().count(), "2 docs expected after upsert failure"); diff --git a/jstests/core/apply_ops_dups.js b/jstests/core/apply_ops_dups.js index 268482e3251..dac2f40bd04 100644 --- a/jstests/core/apply_ops_dups.js +++ b/jstests/core/apply_ops_dups.js @@ -2,6 +2,8 @@ * @tags: [ * requires_non_retryable_commands, * requires_fastcount, + * # 6.2 removes support for atomic applyOps + * requires_fcv_62, * # applyOps is not supported on mongos * assumes_against_mongod_not_mongos, * # applyOps uses the oplog that require replication support @@ -50,5 +52,7 @@ var a = assert.commandFailedWithCode(db.adminCommand({ ] }), ErrorCodes.DuplicateKey); -assert.eq(prevCount, t.find().count(), "Invalid insert worked"); +// We do not applyOps atomically, so the first op is applied and the second is not. The total number +// is now 2. +assert.eq(2, t.find().count(), "Expected 2 documents after applyOps"); })(); diff --git a/jstests/core/apply_ops_missing_field.js b/jstests/core/apply_ops_missing_field.js index c392c473ec8..290c60bd446 100644 --- a/jstests/core/apply_ops_missing_field.js +++ b/jstests/core/apply_ops_missing_field.js @@ -26,10 +26,8 @@ const coll = db.getCollection(jsTestName()); coll.drop(); -// Run applyOps as MongoMirror does, with a dummy command to make it non-atomic. MongoMirror does -// not use allowAtomic: false. +// Run applyOps. function applyOps(ops) { - ops.push({op: "c", ns: "admin.$cmd", o: {applyOps: [{op: "n", ns: "", o: {"msg": "noop"}}]}}); let command = {applyOps: ops, writeConcern: {w: "majority"}}; assert.commandWorked(db.adminCommand(command)); } diff --git a/jstests/core/bypass_doc_validation.js b/jstests/core/bypass_doc_validation.js index d499e1560fa..976bee5d14e 100644 --- a/jstests/core/bypass_doc_validation.js +++ b/jstests/core/bypass_doc_validation.js @@ -2,6 +2,8 @@ // does_not_support_stepdowns, // does_not_support_transactions, // requires_fastcount, +// # 6.2 removes support for atomic applyOps +// requires_fcv_62, // requires_non_retryable_commands, // uses_map_reduce_with_temp_collections, // # Tenant migrations don't support applyOps. @@ -54,8 +56,9 @@ function runBypassDocumentValidationTest(validator) { // Test applyOps with a simple insert if not on mongos. if (!isMongos) { const op = [{op: 'i', ns: coll.getFullName(), o: {_id: 9}}]; - assertDocumentValidationFailure( - myDb.runCommand({applyOps: op, bypassDocumentValidation: false}), coll); + const res = myDb.runCommand({applyOps: op, bypassDocumentValidation: false}); + assert.commandFailedWithCode(res, ErrorCodes.UnknownError, tojson(res)); + assertDocumentValidationFailureCheckLogs(myDb); assert.eq(0, coll.count({_id: 9})); assert.commandWorked(myDb.runCommand({applyOps: op, bypassDocumentValidation: true})); assert.eq(1, coll.count({_id: 9})); diff --git a/jstests/libs/doc_validation_utils.js b/jstests/libs/doc_validation_utils.js index 71ce072e6a0..6d3e489cbff 100644 --- a/jstests/libs/doc_validation_utils.js +++ b/jstests/libs/doc_validation_utils.js @@ -20,3 +20,10 @@ function assertDocumentValidationFailure(res, coll) { assert.eq(typeof error["errInfo"], "object", tojson(error)); } } + +/** + * Verifies that the logs contain DocumentValidationFailure. + */ +function assertDocumentValidationFailureCheckLogs(db) { + checkLog.contains(db, '"codeName":"DocumentValidationFailure"'); +} diff --git a/jstests/noPassthrough/apply_ops_atomic.js b/jstests/noPassthrough/apply_ops_atomic.js deleted file mode 100644 index 9e62a1c74e3..00000000000 --- a/jstests/noPassthrough/apply_ops_atomic.js +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Validates atomic applyOps operations, including UUID propagation and replicating the actual - * writes rather than the operations that were requested from the applyOps command. - * - * @tags: [ - * requires_replication, - * ] - */ - -(function() { -'use strict'; -load('jstests/libs/uuid_util.js'); // For getUUIDFromListCollections - -const rst = new ReplSetTest({ - name: "apply_ops_atomic_test", - nodes: 2, -}); - -rst.startSet(); -rst.initiate(); -rst.awaitNodesAgreeOnPrimary(); - -const conn = rst.getPrimary(); -const db = conn.getDB("applyOpsAtomic"); -const coll = db.getCollection('test'); - -assert.commandWorked(db.createCollection(coll.getName())); -const collUUID = getUUIDFromListCollections(db, coll.getName()); - -function validateInsertApplyOpsInOplog(conn, ns, uuid, id) { - assert.eq( - 1, - conn.getDB('local') - .oplog.rs - .find({ - 'op': 'c', - ns: 'admin.$cmd', - 'o.applyOps': {$elemMatch: {op: 'i', ns: ns, ui: uuid, 'o._id': id, 'o2._id': id}} - }) - .itcount()); -} - -// Validates that an insert inside a nested applyOps succeeds. -{ - const collCountBefore = coll.find().itcount(); - const id = "InsertInNestedApplyOpsReturnsSuccess"; - assert.eq(0, coll.find({"_id": id}).itcount()); - const op = { - applyOps: [{ - op: 'c', - ns: 'admin.$cmd', - o: {applyOps: [{op: 'i', ns: coll.getFullName(), ui: collUUID, o: {_id: id}}]} - }] - }; - assert.commandWorked(db.runCommand(op)); - assert.eq(1, coll.find({"_id": id}).itcount()); - assert.eq(collCountBefore + 1, coll.find().itcount()); - validateInsertApplyOpsInOplog(conn, coll.getFullName(), collUUID, id); -} - -// Validates that an empty applyOps succeeds. -{ - const collCountBefore = coll.find().itcount(); - const latestApplyOpsInOplogTimestamp = - db.getSiblingDB('local') - .oplog.rs.find({ns: 'admin.$cmd', 'o.applyOps': {$exists: true}}) - .sort({$natural: -1})[0] - .ts; - assert.commandWorked(db.runCommand({applyOps: []})); - assert.eq(collCountBefore, coll.find().itcount()); - // No applyOps is emitted. - assert.eq(latestApplyOpsInOplogTimestamp, - db.getSiblingDB('local') - .oplog.rs.find({ns: 'admin.$cmd', 'o.applyOps': {$exists: true}}) - .sort({$natural: -1})[0] - .ts); -} - -// Validates that an applyOps command that specifies the collection UUID replicates an applyOps -// entry that includes the collection UUID. -{ - const collCountBefore = coll.find().itcount(); - const id = "AtomicApplyOpsInsertWithUuidIntoCollectionWithUuid"; - assert.eq(0, coll.find({"_id": id}).itcount()); - const op = {applyOps: [{op: 'i', ns: coll.getFullName(), ui: collUUID, o: {_id: id}}]}; - assert.commandWorked(db.runCommand(op)); - assert.eq(1, coll.find({"_id": id}).itcount()); - assert.eq(collCountBefore + 1, coll.find().itcount()); - validateInsertApplyOpsInOplog(conn, coll.getFullName(), collUUID, id); -} - -// Validates that an applyOps command that doesn't specify the collection UUID replicates an -// applyOps entry that includes the collection UUID. -{ - const collCountBefore = coll.find().itcount(); - const id = "AtomicApplyOpsInsertWithoutUuidIntoCollectionWithUuid"; - assert.eq(0, coll.find({"_id": id}).itcount()); - const op = {applyOps: [{op: 'i', ns: coll.getFullName(), o: {_id: id}}]}; - assert.commandWorked(db.runCommand(op)); - assert.eq(1, coll.find({"_id": id}).itcount()); - assert.eq(collCountBefore + 1, coll.find().itcount()); - validateInsertApplyOpsInOplog(conn, coll.getFullName(), collUUID, id); -} - -// The applyOps command replicates what it wrote, not what it was asked to do. Validate that an -// update that results in an upsert replicates as an insert operation, not as an update as it was -// requested by the user via the applyOps command. -{ - const collCountBefore = coll.find().itcount(); - const idUnexisting = "unexistingDocument"; - const idUpserted = "upsertedDocument"; - assert.eq(0, coll.find({"_id": idUnexisting}).itcount()); - assert.eq(0, coll.find({"_id": idUpserted}).itcount()); - const op = { - applyOps: [{ - op: 'u', - ns: coll.getFullName(), - o2: {_id: idUnexisting}, - o: {$v: 2, diff: {u: {_id: idUpserted}}} - }] - }; - assert.commandWorked(db.runCommand(op)); - assert.eq(0, coll.find({"_id": idUnexisting}).itcount()); - assert.eq(1, coll.find({"_id": idUpserted}).itcount()); - assert.eq(collCountBefore + 1, coll.find().itcount()); - validateInsertApplyOpsInOplog(conn, coll.getFullName(), collUUID, idUpserted); -} - -// applyOps to a collection with pre-images enabled falls back to non-atomic mode. -{ - const preImageCollName = 'c'; - const coll = db.getCollection(preImageCollName); - assert.commandWorked( - db.createCollection(preImageCollName, {changeStreamPreAndPostImages: {enabled: true}})); - assert.eq(0, coll.find().itcount()); - assert.commandWorked(db.c.insertOne({_id: 1, a: "a"})); - assert.eq(1, coll.find({_id: 1, a: "a"}).itcount()); - assert.commandWorked(db.runCommand({ - applyOps: [{ - op: 'u', - ns: coll.getFullName(), - o2: {_id: 1}, - o: {$v: 2, diff: {u: {a: "b"}}}, - }] - })); - assert.eq(1, coll.find().itcount()); - assert.eq(1, coll.find({_id: 1, a: "b"}).itcount()); - assert.eq( - 1, - conn.getDB('local') - .oplog.rs.find({'op': 'u', ns: coll.getFullName(), 'o.diff.u.a': 'b', 'o2._id': 1}) - .itcount()); -} - -rst.stopSet(); -})(); diff --git a/jstests/noPassthrough/non_atomic_apply_ops_logging.js b/jstests/noPassthrough/apply_ops_logging.js index 64ff7159d3a..72572b6f803 100644 --- a/jstests/noPassthrough/non_atomic_apply_ops_logging.js +++ b/jstests/noPassthrough/apply_ops_logging.js @@ -19,20 +19,8 @@ testDB.runCommand({drop: rerenamedCollName}); assert.commandWorked(testDB.runCommand({create: testCollName})); let testColl = testDB[testCollName]; -// Ensure atomic apply ops logging only produces one oplog entry -// per call to apply ops and does not log individual operations -// separately. -assert.commandWorked(testDB.runCommand({ - applyOps: [ - {op: "i", ns: testColl.getFullName(), o: {_id: 1, a: "foo"}}, - {op: "i", ns: testColl.getFullName(), o: {_id: 2, a: "bar"}} - ] -})); -assert.eq(oplogColl.find({"o.applyOps": {"$exists": true}}).count(), 1); -assert.eq(oplogColl.find({op: "i", ns: testColl.getFullName()}).count(), 0); -// Ensure non-atomic apply ops logging produces an oplog entry for -// each operation in the apply ops call and no record of applyOps -// appears for these operations. +// Ensure applyOps logging produces an oplog entry for each operation in the applyOps call and no +// record of applyOps appears for these operations. assert.commandWorked(testDB.runCommand({ applyOps: [ { @@ -58,22 +46,21 @@ assert.commandWorked(testDB.runCommand({ ] })); assert.eq(oplogColl.find({"o.renameCollection": {"$exists": true}}).count(), 2); -assert.eq(oplogColl.find({"o.applyOps": {"$exists": true}}).count(), 1); +assert.eq(oplogColl.find({"o.applyOps": {"$exists": true}}).count(), 0); -// Ensure that applyOps respects the 'allowAtomic' boolean flag on CRUD operations that it would -// have applied atomically. +// Since atomic applyOps cannot run atomically, this test ensures that applyOps ignores the +// 'allowAtomic' field. We fail to insert a duplicate doc, and ensure that the original doc was +// inserted successfully. Atomic applyOps would fail to insert both documents. assert.commandWorked(testDB.createCollection(testColl.getName())); -assert.commandFailedWithCode(testDB.runCommand({applyOps: [], allowAtomic: 'must be boolean'}), - ErrorCodes.TypeMismatch, - 'allowAtomic flag must be a boolean.'); assert.commandWorked(testDB.runCommand({ applyOps: [ {op: "i", ns: testColl.getFullName(), o: {_id: 3, a: "augh"}}, {op: "i", ns: testColl.getFullName(), o: {_id: 4, a: "blah"}} ], - allowAtomic: false, + allowAtomic: true, })); -assert.eq(oplogColl.find({"o.applyOps": {"$exists": true}}).count(), 1); + +assert.eq(oplogColl.find({"o.applyOps": {"$exists": true}}).count(), 0); assert.eq(oplogColl.find({op: "i", ns: testColl.getFullName()}).count(), 2); rst.stopSet(); diff --git a/jstests/noPassthrough/write_change_stream_pit_preimage_in_transaction.js b/jstests/noPassthrough/write_change_stream_pit_preimage_in_transaction.js index 439835b6082..3801e371b0d 100644 --- a/jstests/noPassthrough/write_change_stream_pit_preimage_in_transaction.js +++ b/jstests/noPassthrough/write_change_stream_pit_preimage_in_transaction.js @@ -1,6 +1,6 @@ /** * Tests that pre-images are written to the pre-images collection on updates and deletes in - * transactions and for non-atomic "applyOps" command. + * transactions and for "applyOps" command. * @tags: [ * requires_fcv_60, * requires_replication, @@ -200,7 +200,7 @@ function getCollections(db) { assert.commandWorked(coll.deleteMany({})); assert.commandWorked(coll.insert([{_id: 1, a: 1}, {_id: 2, a: 1}])); - // Verify that pre-images are written correctly for the non-atomic "applyOps" command. + // Verify that pre-images are written correctly for the "applyOps" command. assertPreImagesWrittenForOps(testDB, function() { assert.commandWorked(testDB.runCommand({ applyOps: [ @@ -212,22 +212,6 @@ function getCollections(db) { }, [{_id: 1, a: 1}, {_id: 2, a: 1}]); })(); -(function testPreImageWritingForAtomicApplyOpsCommandAutoConvertedToNonAtomic() { - assert.commandWorked(coll.deleteMany({})); - assert.commandWorked(coll.insert([{_id: 1, a: 1}, {_id: 2, a: 1}])); - - // Verify that pre-images are written correctly for the atomic "applyOps" command, which is - // automatically converted to a non-atomic one. - assertPreImagesWrittenForOps(testDB, function() { - assert.commandWorked(testDB.runCommand({ - applyOps: [ - {op: "u", ns: coll.getFullName(), o2: {_id: 1}, o: {$v: 2, diff: {u: {a: 2}}}}, - {op: "d", ns: coll.getFullName(), o: {_id: 2}} - ], - })); - }, [{_id: 1, a: 1}, {_id: 2, a: 1}]); -})(); - (function testPreImageWritingForPreparedTransaction() { assert.commandWorked(coll.deleteMany({})); assert.commandWorked(coll.insert([{_id: 1, a: 1}, {_id: 3, a: 1}, {_id: 11}])); diff --git a/jstests/noPassthroughWithMongod/apply_ops_errors.js b/jstests/noPassthroughWithMongod/apply_ops_errors.js index 2e2fb2d6069..fb0a3450a46 100644 --- a/jstests/noPassthroughWithMongod/apply_ops_errors.js +++ b/jstests/noPassthroughWithMongod/apply_ops_errors.js @@ -52,6 +52,7 @@ var res = db.runCommand({ assert.eq(2, res.applied); assert(res.code); assert(res.errmsg); -assert.eq([false, false], res.results); +// applyOps is non-atomic +assert.eq([true, false], res.results); assert.eq(0, res.ok); })(); diff --git a/jstests/replsets/apply_ops_concurrent_different_db.js b/jstests/replsets/apply_ops_concurrent_different_db.js new file mode 100644 index 00000000000..2827965d959 --- /dev/null +++ b/jstests/replsets/apply_ops_concurrent_different_db.js @@ -0,0 +1,13 @@ +/** + * @tags: [ + * # 6.2 removes support for atomic applyOps + * requires_fcv_62, + * ] + */ +(function() { +'use strict'; + +load('jstests/replsets/libs/apply_ops_concurrent.js'); + +new ApplyOpsConcurrentTest({ns1: 'test1.coll1', ns2: 'test2.coll2'}).run(); +}()); diff --git a/jstests/replsets/apply_ops_concurrent_non_atomic_different_db.js b/jstests/replsets/apply_ops_concurrent_non_atomic_different_db.js deleted file mode 100644 index cfd905e8f1b..00000000000 --- a/jstests/replsets/apply_ops_concurrent_non_atomic_different_db.js +++ /dev/null @@ -1,7 +0,0 @@ -(function() { -'use strict'; - -load('jstests/replsets/libs/apply_ops_concurrent_non_atomic.js'); - -new ApplyOpsConcurrentNonAtomicTest({ns1: 'test1.coll1', ns2: 'test2.coll2'}).run(); -}()); diff --git a/jstests/replsets/apply_ops_concurrent_non_atomic_same_collection.js b/jstests/replsets/apply_ops_concurrent_non_atomic_same_collection.js deleted file mode 100644 index 8fee43697cf..00000000000 --- a/jstests/replsets/apply_ops_concurrent_non_atomic_same_collection.js +++ /dev/null @@ -1,7 +0,0 @@ -(function() { -'use strict'; - -load('jstests/replsets/libs/apply_ops_concurrent_non_atomic.js'); - -new ApplyOpsConcurrentNonAtomicTest({ns1: 'test.coll', ns2: 'test.coll'}).run(); -}()); diff --git a/jstests/replsets/apply_ops_concurrent_non_atomic_same_db.js b/jstests/replsets/apply_ops_concurrent_non_atomic_same_db.js deleted file mode 100644 index 2f4aa37199c..00000000000 --- a/jstests/replsets/apply_ops_concurrent_non_atomic_same_db.js +++ /dev/null @@ -1,7 +0,0 @@ -(function() { -'use strict'; - -load('jstests/replsets/libs/apply_ops_concurrent_non_atomic.js'); - -new ApplyOpsConcurrentNonAtomicTest({ns1: 'test.coll1', ns2: 'test.coll2'}).run(); -}()); diff --git a/jstests/replsets/apply_ops_concurrent_same_collection.js b/jstests/replsets/apply_ops_concurrent_same_collection.js new file mode 100644 index 00000000000..7b9057f8eb5 --- /dev/null +++ b/jstests/replsets/apply_ops_concurrent_same_collection.js @@ -0,0 +1,13 @@ +/** + * @tags: [ + * # 6.2 removes support for atomic applyOps + * requires_fcv_62, + * ] + */ +(function() { +'use strict'; + +load('jstests/replsets/libs/apply_ops_concurrent.js'); + +new ApplyOpsConcurrentTest({ns1: 'test.coll', ns2: 'test.coll'}).run(); +}()); diff --git a/jstests/replsets/apply_ops_concurrent_same_db.js b/jstests/replsets/apply_ops_concurrent_same_db.js new file mode 100644 index 00000000000..09e1db22bb7 --- /dev/null +++ b/jstests/replsets/apply_ops_concurrent_same_db.js @@ -0,0 +1,13 @@ +/** + * @tags: [ + * # 6.2 removes support for atomic applyOps + * requires_fcv_62, + * ] + */ +(function() { +'use strict'; + +load('jstests/replsets/libs/apply_ops_concurrent.js'); + +new ApplyOpsConcurrentTest({ns1: 'test.coll1', ns2: 'test.coll2'}).run(); +}()); diff --git a/jstests/replsets/apply_ops_idempotency.js b/jstests/replsets/apply_ops_idempotency.js index 41f320375a6..5f3dd9ea25c 100644 --- a/jstests/replsets/apply_ops_idempotency.js +++ b/jstests/replsets/apply_ops_idempotency.js @@ -46,7 +46,8 @@ function assertApplyOpsWorks(testdbs, ops) { ops.shift(); // These errors are expected when replaying operations and should be ignored. - if (res.code == ErrorCodes.NamespaceNotFound || res.code == ErrorCodes.DuplicateKey) { + if (res.code == ErrorCodes.NamespaceNotFound || res.code == ErrorCodes.DuplicateKey || + res.code == ErrorCodes.UnknownError) { ops.shift(); continue; } diff --git a/jstests/replsets/apply_ops_insert_write_conflict.js b/jstests/replsets/apply_ops_insert_write_conflict.js new file mode 100644 index 00000000000..ec7b9ddbbe9 --- /dev/null +++ b/jstests/replsets/apply_ops_insert_write_conflict.js @@ -0,0 +1,12 @@ +/** + * @tags: [ + * requires_fcv_62, + * ] + */ +(function() { +'use strict'; + +load("jstests/replsets/libs/apply_ops_insert_write_conflict.js"); + +new ApplyOpsInsertWriteConflictTest({testName: 'apply_ops_insert_write_conflict'}).run(); +}()); diff --git a/jstests/replsets/apply_ops_insert_write_conflict_atomic.js b/jstests/replsets/apply_ops_insert_write_conflict_atomic.js deleted file mode 100644 index 47d35d4e7df..00000000000 --- a/jstests/replsets/apply_ops_insert_write_conflict_atomic.js +++ /dev/null @@ -1,10 +0,0 @@ -(function() { -'use strict'; - -load("jstests/replsets/libs/apply_ops_insert_write_conflict.js"); - -new ApplyOpsInsertWriteConflictTest({ - testName: 'apply_ops_insert_write_conflict_atomic', - atomic: true -}).run(); -}()); diff --git a/jstests/replsets/apply_ops_insert_write_conflict_nonatomic.js b/jstests/replsets/apply_ops_insert_write_conflict_nonatomic.js deleted file mode 100644 index a7843716bac..00000000000 --- a/jstests/replsets/apply_ops_insert_write_conflict_nonatomic.js +++ /dev/null @@ -1,10 +0,0 @@ -(function() { -'use strict'; - -load("jstests/replsets/libs/apply_ops_insert_write_conflict.js"); - -new ApplyOpsInsertWriteConflictTest({ - testName: 'apply_ops_insert_write_conflict_nonatomic', - atomic: false -}).run(); -}()); diff --git a/jstests/replsets/apply_ops_inserts_do_not_include_fromMigrate_field.js b/jstests/replsets/apply_ops_inserts_do_not_include_fromMigrate_field.js index 2b7d8729b61..a5118514db2 100644 --- a/jstests/replsets/apply_ops_inserts_do_not_include_fromMigrate_field.js +++ b/jstests/replsets/apply_ops_inserts_do_not_include_fromMigrate_field.js @@ -34,9 +34,9 @@ const secondaryChangeStream = secondaryCST.startWatchingAllChangesForCluster(); primaryDB.createCollection(collName); -// Test non-atomic applyOps inserts. -assert.commandWorked(primaryDB.runCommand( - {applyOps: [{op: "i", ns: nss(dbName, collName), o: {_id: 0}}], allowAtomic: false})); +// Test applyOps inserts. +assert.commandWorked( + primaryDB.runCommand({applyOps: [{op: "i", ns: nss(dbName, collName), o: {_id: 0}}]})); assert.commandWorked(primaryDB.runCommand({ applyOps: [ {op: "i", ns: nss(dbName, collName), o: {_id: 1}}, @@ -44,10 +44,9 @@ assert.commandWorked(primaryDB.runCommand({ ] })); -// Test non-atomic applyOps upserts. These will be logged as insert oplog entries. +// Test applyOps upserts. These will be logged as insert oplog entries. assert.commandWorked(primaryDB.runCommand({ - applyOps: [{op: "u", ns: nss(dbName, collName), o2: {_id: 2}, o: {$v: 2, diff: {u: {x: 2}}}}], - allowAtomic: false + applyOps: [{op: "u", ns: nss(dbName, collName), o2: {_id: 2}, o: {$v: 2, diff: {u: {x: 2}}}}] })); assert.commandWorked(primaryDB.runCommand({ @@ -56,56 +55,27 @@ assert.commandWorked(primaryDB.runCommand({ {op: "c", ns: nss(dbName, "$cmd"), o: {create: "other2"}} ] })); - -// Test atomic applyOps inserts. -// TODO (SERVER-33182): Remove the atomic applyOps testing once atomic applyOps are removed. -assert.commandWorked( - primaryDB.runCommand({applyOps: [{op: "i", ns: nss(dbName, collName), o: {_id: 4}}]})); -assert.commandWorked(primaryDB.runCommand({ - applyOps: [ - {op: "i", ns: nss(dbName, collName), o: {_id: 5}}, - {op: "i", ns: nss(dbName, collName), o: {_id: 6}}, - ] -})); rst.awaitReplication(); -assert.eq(7, primaryDB[collName].find().toArray().length); +assert.eq(4, primaryDB[collName].find().toArray().length); let expectedCount = 0; const oplog = rst.getPrimary().getDB("local").getCollection("oplog.rs"); -const nonAtomicResults = oplog.find({ns: nss(dbName, collName)}).toArray(); -assert.eq(nonAtomicResults.length, 4, nonAtomicResults); -nonAtomicResults.forEach(function(op) { - // We expect non-atomic applyOps inserts to be picked up by changeStreams. +const results = oplog.find({ns: nss(dbName, collName)}).toArray(); +assert.eq(results.length, 4, results); +results.forEach(function(op) { + // We expect applyOps inserts to be picked up by changeStreams. const primaryChange = primaryCST.getOneChange(primaryChangeStream); assert.eq(primaryChange.documentKey._id, expectedCount, primaryChange); const secondaryChange = secondaryCST.getOneChange(secondaryChangeStream); assert.eq(secondaryChange.documentKey._id, expectedCount, secondaryChange); - assert.eq(op.o._id, expectedCount++, nonAtomicResults); - assert(!op.hasOwnProperty("fromMigrate"), nonAtomicResults); + assert.eq(op.o._id, expectedCount++, results); + assert(!op.hasOwnProperty("fromMigrate"), results); }); -// Atomic applyOps inserts are expected to be picked up by changeStreams. -// We expect the operations from an atomic applyOps command to be nested in an applyOps oplog entry. -const atomicResults = oplog.find({"o.applyOps": {$exists: true}}).toArray(); -assert.eq(atomicResults.length, 2, atomicResults); -for (let i = 0; i < atomicResults.length; i++) { - let ops = atomicResults[i].o.applyOps; - ops.forEach(function(op) { - const primaryChange = primaryCST.getOneChange(primaryChangeStream); - assert.eq(primaryChange.documentKey._id, expectedCount, primaryChange); - const secondaryChange = secondaryCST.getOneChange(secondaryChangeStream); - assert.eq(secondaryChange.documentKey._id, expectedCount, secondaryChange); - assert.eq(op.o._id, expectedCount++, atomicResults); - assert(!op.hasOwnProperty("fromMigrate"), atomicResults); - }); -} - primaryCST.assertNoChange(primaryChangeStream); secondaryCST.assertNoChange(secondaryChangeStream); -assert.eq(7, expectedCount); - rst.stopSet(); })(); diff --git a/jstests/replsets/change_stream_pit_pre_images.js b/jstests/replsets/change_stream_pit_pre_images.js index 5434b5a3d4d..a09adb23398 100644 --- a/jstests/replsets/change_stream_pit_pre_images.js +++ b/jstests/replsets/change_stream_pit_pre_images.js @@ -5,7 +5,8 @@ * The test relies on a correct change stream pre-image recording on a node in the primary role. * * @tags: [ - * requires_fcv_60, + * # 6.2 removes support for atomic applyOps + * requires_fcv_62, * # The test waits for the Checkpointer, but this process runs only for on-disk storage engines. * requires_persistence, * ] @@ -110,7 +111,7 @@ for (const [collectionName, collectionOptions] of [ assert.commandWorked(PrepareHelpers.commitTransaction(session, prepareTimestamp)); } - function issueNonAtomicApplyOpsCommand(testDB) { + function issueApplyOpsCommand(testDB) { assert.commandWorked(coll.deleteMany({$and: [{_id: {$gte: 9}}, {_id: {$lte: 10}}]})); assert.commandWorked(coll.insert([{_id: 9, a: 1}, {_id: 10, a: 1}])); assert.commandWorked(testDB.runCommand({ @@ -118,7 +119,6 @@ for (const [collectionName, collectionOptions] of [ {op: "u", ns: coll.getFullName(), o2: {_id: 9}, o: {$v: 2, diff: {u: {a: 2}}}}, {op: "d", ns: coll.getFullName(), o: {_id: 10}} ], - allowAtomic: false, })); } @@ -156,7 +156,7 @@ for (const [collectionName, collectionOptions] of [ replTest.awaitReplication(); assertPreImagesCollectionOnPrimaryMatchesSecondary(); - issueNonAtomicApplyOpsCommand(testDB); + issueApplyOpsCommand(testDB); // Verify that related change stream pre-images were replicated to the secondary. replTest.awaitReplication(); @@ -194,7 +194,7 @@ for (const [collectionName, collectionOptions] of [ assert.commandWorked(coll.deleteOne({_id: 3}, {writeConcern: {w: 2}})); issueRetryableFindAndModifyCommands(testDB); - issueNonAtomicApplyOpsCommand(testDB); + issueApplyOpsCommand(testDB); issueWriteCommandsInTransaction(testDB); // Resume the initial sync process. @@ -238,7 +238,7 @@ for (const [collectionName, collectionOptions] of [ assert.commandWorked(coll.deleteOne({_id: 4}, {writeConcern: {w: 2}})); issueRetryableFindAndModifyCommands(testDB); - issueNonAtomicApplyOpsCommand(testDB); + issueApplyOpsCommand(testDB); issueWriteCommandsInTransaction(testDB); // Do an unclean shutdown of the primary node, and then restart. diff --git a/jstests/replsets/initial_sync_update_missing_doc_upsert.js b/jstests/replsets/initial_sync_update_missing_doc_upsert.js index 0c5db031730..d247db483b9 100644 --- a/jstests/replsets/initial_sync_update_missing_doc_upsert.js +++ b/jstests/replsets/initial_sync_update_missing_doc_upsert.js @@ -48,7 +48,7 @@ assert.commandWorked(coll.update({_id: documentIdCounter}, {x: 1}, {upsert: true documentIdCounter++; numDocuments++; -function applyOps({documentId, alwaysUpsert, allowAtomic}) { +function applyOps({documentId, alwaysUpsert}) { let command = { applyOps: [ {op: "u", ns: coll.getFullName(), o2: {_id: documentId}, o: {$v: 2, diff: {u: {x: 1}}}} @@ -59,39 +59,29 @@ function applyOps({documentId, alwaysUpsert, allowAtomic}) { command['alwaysUpsert'] = alwaysUpsert; } - if (allowAtomic !== null) { - command['allowAtomic'] = allowAtomic; - } - assert.commandWorked(primary.getDB(dbName).runCommand(command)); } /* alwaysUpsert is true by default; test with the default value and an explicit value */ for (let alwaysUpsert of [null, true]) { - /* If allowAtomic is true (the default), this writes an applyOps oplog entry containing an - * op: 'u' sub-entry, otherwise it writes a regular op: 'u' entry. The update is treated as + /* It writes a regular op: 'u' entry. The update is treated as * an upsert by the primary. Ensure it is treated that way by the secondary when it applies * the oplog entry during initial sync. */ - for (let allowAtomic of [null, true, false]) { - applyOps( - {documentId: documentIdCounter, alwaysUpsert: alwaysUpsert, allowAtomic: allowAtomic}); - documentIdCounter++; - numDocuments++; - } + applyOps({documentId: documentIdCounter, alwaysUpsert: alwaysUpsert}); + documentIdCounter++; + numDocuments++; } /* The interesting scenario for alwaysUpsert: false is if the document is deleted on the primary * after updating. When the secondary attempts to apply the oplog entry during initial sync, * it will fail to update. Ensure that initial sync proceeds anyway. */ -for (let allowAtomic of [null, true, false]) { - coll.insertOne({_id: documentIdCounter}); - applyOps({documentId: documentIdCounter, alwaysUpsert: false, allowAtomic: allowAtomic}); - coll.deleteOne({_id: documentIdCounter}); - // Don't increment numDocuments, since we deleted the document we just inserted. - documentIdCounter++; -} +coll.insertOne({_id: documentIdCounter}); +applyOps({documentId: documentIdCounter, alwaysUpsert: false}); +coll.deleteOne({_id: documentIdCounter}); +// Don't increment numDocuments, since we deleted the document we just inserted. +documentIdCounter++; jsTestLog("Allow initial sync to finish fetching and replaying oplog"); diff --git a/jstests/replsets/libs/apply_ops_concurrent_non_atomic.js b/jstests/replsets/libs/apply_ops_concurrent.js index 811735573c2..29ff1a6a045 100644 --- a/jstests/replsets/libs/apply_ops_concurrent_non_atomic.js +++ b/jstests/replsets/libs/apply_ops_concurrent.js @@ -1,9 +1,9 @@ /** - * This test ensures that multiple non-atomic applyOps commands can run concurrently. + * This test ensures that multiple applyOps commands can run concurrently. * Prior to SERVER-29802, applyOps would acquire the global lock regardless of the * atomicity of the operations (as a whole) being applied. * - * Every instance of ApplyOpsConcurrentNonAtomicTest is configured with an "options" document + * Every instance of ApplyOpsConcurrentTest is configured with an "options" document * with the following format: * { * ns1: <string>, @@ -19,13 +19,13 @@ * Fully qualified namespace of second set of CRUD operations. This may be the same namespace as * ns1. As with ns1, only insert operations will be used. */ -var ApplyOpsConcurrentNonAtomicTest = function(options) { +var ApplyOpsConcurrentTest = function(options) { 'use strict'; load('jstests/concurrency/fsm_workload_helpers/server_types.js'); - if (!(this instanceof ApplyOpsConcurrentNonAtomicTest)) { - return new ApplyOpsConcurrentNonAtomicTest(options); + if (!(this instanceof ApplyOpsConcurrentTest)) { + return new ApplyOpsConcurrentTest(options); } // Capture the 'this' reference @@ -37,7 +37,7 @@ var ApplyOpsConcurrentNonAtomicTest = function(options) { * Logs message using test name as prefix. */ function testLog(message) { - jsTestLog('ApplyOpsConcurrentNonAtomicTest: ' + message); + jsTestLog('ApplyOpsConcurrentTest: ' + message); } /** @@ -55,13 +55,13 @@ var ApplyOpsConcurrentNonAtomicTest = function(options) { } /** - * Runs applyOps in non-atomic mode to insert 'numOps' documents into collection 'coll'. + * Runs applyOps to insert 'numOps' documents into collection 'coll'. */ - function applyOpsInsertNonAtomic(coll, numOps, id) { + function applyOpsInsert(coll, numOps, id) { 'use strict'; const ops = generateInsertOps(coll, numOps, id); const mydb = coll.getDB(); - assert.commandWorked(mydb.runCommand({applyOps: ops, allowAtomic: false}), + assert.commandWorked(mydb.runCommand({applyOps: ops}), 'failed to insert documents into ' + coll.getFullName()); } @@ -94,7 +94,7 @@ var ApplyOpsConcurrentNonAtomicTest = function(options) { const id = options.id; testLog('Starting to apply ' + numOps + ' operations in collection ' + coll.getFullName()); - applyOpsInsertNonAtomic(coll, numOps, id); + applyOpsInsert(coll, numOps, id); testLog('Successfully applied ' + numOps + ' operations in collection ' + coll.getFullName()); } @@ -110,13 +110,13 @@ var ApplyOpsConcurrentNonAtomicTest = function(options) { id: id, }; const functionName = 'insertFunction_' + coll.getFullName().replace(/\./g, '_'); - const s = // - '\n\n' + // - 'const testLog = ' + testLog + ';\n\n' + // - 'const generateInsertOps = ' + generateInsertOps + ';\n\n' + // - 'const applyOpsInsertNonAtomic = ' + applyOpsInsertNonAtomic + ';\n\n' + // - 'const ' + functionName + ' = ' + insertFunction + ';\n\n' + // - functionName + '(' + tojson(options) + ');'; // + const s = // + '\n\n' + // + 'const testLog = ' + testLog + ';\n\n' + // + 'const generateInsertOps = ' + generateInsertOps + ';\n\n' + // + 'const applyOpsInsert = ' + applyOpsInsert + ';\n\n' + // + 'const ' + functionName + ' = ' + insertFunction + ';\n\n' + // + functionName + '(' + tojson(options) + ');'; // return s; } diff --git a/jstests/replsets/libs/apply_ops_insert_write_conflict.js b/jstests/replsets/libs/apply_ops_insert_write_conflict.js index 4cbdbe18e88..5915bd2c104 100644 --- a/jstests/replsets/libs/apply_ops_insert_write_conflict.js +++ b/jstests/replsets/libs/apply_ops_insert_write_conflict.js @@ -40,10 +40,7 @@ var ApplyOpsInsertWriteConflictTest = function(options) { }); // Probabilities for WCE are chosen based on empirical testing. - // The probability for WCE during an atomic applyOps should be much smaller than that for - // the non-atomic case because we have to attempt to re-apply the entire batch of 'numOps' - // operations on WCE in the atomic case. - var probability = (options.atomic ? 0.1 : 5.0) / numOps; + var probability = 5.0 / numOps; // Set up failpoint to trigger WriteConflictException during write operations. assert.commandWorked( @@ -57,7 +54,7 @@ var ApplyOpsInsertWriteConflictTest = function(options) { var previousLogLevel = assert.commandWorked(primaryDB.setLogLevel(3, 'replication')).was.replication.verbosity; - var applyOpsResult = primaryDB.adminCommand({applyOps: ops, allowAtomic: options.atomic}); + var applyOpsResult = primaryDB.adminCommand({applyOps: ops}); // Reset log level. primaryDB.setLogLevel(previousLogLevel, 'replication'); diff --git a/jstests/replsets/opcounters_repl.js b/jstests/replsets/opcounters_repl.js index ec870ee71e6..4bc09cf8dad 100644 --- a/jstests/replsets/opcounters_repl.js +++ b/jstests/replsets/opcounters_repl.js @@ -89,7 +89,7 @@ diff = getOpCountersDiff(() => { assert.eq(diff.primary.delete, 1); assert.eq(diff.secondary.delete, 1); -// 5. Atomic insert operation via applyOps cmd. +// 5. Insert operation via applyOps cmd. diff = getOpCountersDiff(() => { assert.commandWorked(primaryColl.runCommand( {applyOps: [{op: "i", ns: collNs, o: {_id: 1}}], writeConcern: {w: 2}})); diff --git a/jstests/sharding/resharding_generate_oplog_entries.js b/jstests/sharding/resharding_generate_oplog_entries.js index 2e1815c81ca..8d8d2fe67b0 100644 --- a/jstests/sharding/resharding_generate_oplog_entries.js +++ b/jstests/sharding/resharding_generate_oplog_entries.js @@ -82,7 +82,7 @@ simulateResharding(); let primary = st.shard0; (() => { - jsTestLog("Inserting docs in atomic applyOps"); + jsTestLog("Inserting docs in applyOps"); assert.commandWorked(primary.getDB(dbName).runCommand({ applyOps: |