diff options
author | Huayu Ouyang <huayu.ouyang@mongodb.com> | 2021-05-28 21:08:02 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-01 18:03:10 +0000 |
commit | 42c5d1c871b3760fe0ad4024706b0ed74a71ec22 (patch) | |
tree | f02037289b9126f4cee1289b8b853eb8420779a4 | |
parent | 90eb445e58124ed8b6b46a048834bffe350dad4c (diff) | |
download | mongo-42c5d1c871b3760fe0ad4024706b0ed74a71ec22.tar.gz |
SERVER-57294 Use {w: majority} when creating a collection right before starting transaction in jstests
4 files changed, 7 insertions, 5 deletions
diff --git a/jstests/noPassthrough/server_read_concern_metrics.js b/jstests/noPassthrough/server_read_concern_metrics.js index cb46716f360..2dffe94ba79 100644 --- a/jstests/noPassthrough/server_read_concern_metrics.js +++ b/jstests/noPassthrough/server_read_concern_metrics.js @@ -142,7 +142,7 @@ const collName = "server_read_concern_metrics"; const testDB = primary.getDB(dbName); const testColl = testDB[collName]; testDB.runCommand({drop: collName}); -assert.commandWorked(testDB.createCollection(collName)); +assert.commandWorked(testDB.createCollection(collName, {writeConcern: {w: "majority"}})); assert.commandWorked(testColl.insert({_id: 0}, {writeConcern: {w: 'majority'}})); const isDefaultRCLocalFlagEnabled = isDefaultReadConcernLocalFlagEnabled(primary); diff --git a/jstests/replsets/kill_prepared_transaction_commit_abort.js b/jstests/replsets/kill_prepared_transaction_commit_abort.js index 280cbdc9191..3ba29d65373 100644 --- a/jstests/replsets/kill_prepared_transaction_commit_abort.js +++ b/jstests/replsets/kill_prepared_transaction_commit_abort.js @@ -30,7 +30,7 @@ const testDB = primary.getDB(dbName); // A latch that will act as a signal to shut down the killOp thread. let shutdownLatch = new CountDownLatch(1); -assert.commandWorked(testDB.runCommand({create: collName})); +assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}})); /** * A function that continuously kills any running 'commitTransaction' or 'abortTransaction' commands diff --git a/jstests/replsets/transaction_ops_disallowed_in_applyOps.js b/jstests/replsets/transaction_ops_disallowed_in_applyOps.js index 4a248de35a6..1856079c642 100644 --- a/jstests/replsets/transaction_ops_disallowed_in_applyOps.js +++ b/jstests/replsets/transaction_ops_disallowed_in_applyOps.js @@ -35,7 +35,7 @@ const primarySessionDb = primarySession.getDatabase(dbName); const primarySessionColl = primarySessionDb[collName]; // Create a collection. -assert.commandWorked(primarySessionColl.insert({})); +assert.commandWorked(primarySessionColl.insert({}, {writeConcern: {w: "majority"}})); // // Run transactions of different varieties and record the oplog entries they generate, so that we diff --git a/jstests/sharding/read_write_concern_defaults_application.js b/jstests/sharding/read_write_concern_defaults_application.js index aa0ab90a34a..da3893841fd 100644 --- a/jstests/sharding/read_write_concern_defaults_application.js +++ b/jstests/sharding/read_write_concern_defaults_application.js @@ -142,7 +142,8 @@ let testCases = { abortReshardCollection: {skip: "does not accept read or write concern"}, abortTransaction: { setUp: function(conn) { - assert.commandWorked(conn.getDB(db).runCommand({create: coll, writeConcern: {w: 1}})); + assert.commandWorked( + conn.getDB(db).runCommand({create: coll, writeConcern: {w: 'majority'}})); // Ensure that the dbVersion is known. assert.commandWorked(conn.getCollection(nss).insert({x: 1}, {writeConcern: {w: 1}})); assert.eq(1, @@ -218,7 +219,8 @@ let testCases = { commitReshardCollection: {skip: "does not accept read or write concern"}, commitTransaction: { setUp: function(conn) { - assert.commandWorked(conn.getDB(db).runCommand({create: coll, writeConcern: {w: 1}})); + assert.commandWorked( + conn.getDB(db).runCommand({create: coll, writeConcern: {w: 'majority'}})); // Ensure that the dbVersion is known. assert.commandWorked(conn.getCollection(nss).insert({x: 1}, {writeConcern: {w: 1}})); assert.eq(1, |