summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2018-03-25 01:22:46 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2018-03-25 01:22:46 -0400
commitb910f64caeac3761445eed604fceaf0698e02447 (patch)
tree80c31ce34367f81be5f8d913fe47748b715a23fd
parentde0d0ebfd6365481f41bddda3ff33fd984d65dc6 (diff)
downloadmongo-b910f64caeac3761445eed604fceaf0698e02447.tar.gz
SERVER-28989 Avoid dropping dummy database in checkReplicaSet().
(cherry picked from commit 5c702fedb3216b1a327d3791cd9e995fefc4ab2f) SERVER-30900 removed unnecessary writeConcern from collMod command in ReplSetTest.checkReplicaSet() (cherry picked from commit ac84a0d028eff2b8ca42817d998cb8b34563816c)
-rw-r--r--src/mongo/shell/replsettest.js51
1 files changed, 16 insertions, 35 deletions
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 9d6a4378009..71f4b846470 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -1130,16 +1130,6 @@ var ReplSetTest = function(opts) {
// Call the provided checkerFunction, after the replica set has been write locked.
this.checkReplicaSet = function(checkerFunction, ...checkerFunctionArgs) {
-
- function generateUniqueDbName(dbNames, prefix) {
- var uniqueDbName;
- Random.setRandomSeed();
- do {
- uniqueDbName = prefix + Random.randInt(100000);
- } while (dbNames.has(uniqueDbName));
- return uniqueDbName;
- }
-
assert.eq(typeof checkerFunction,
"function",
"Expected checkerFunction parameter to be a function");
@@ -1148,16 +1138,10 @@ var ReplSetTest = function(opts) {
var primary = this.getPrimary();
assert(primary, 'calling getPrimary() failed');
- // Since we cannot determine if there is a background index in progress (SERVER-26624),
- // we flush indexing as follows:
- // 1. Iterate through all collections and run collMod against each (collMod will block
- // replication to wait for any active background index builds to complete)
- // 2. Insert a document into a dummy collection with a writeConcern for all nodes (which
- // will block on completion of the background index build + collMod)
- var dbNameSet = new Set(primary.getDBNames());
- var uniqueDbName = generateUniqueDbName(dbNameSet, "flush_all_background_indexes_");
-
- for (let dbName of dbNameSet.values()) {
+ // Since we cannot determine if there is a background index in progress (SERVER-26624), we
+ // use the "collMod" command to wait for any index builds that may be in progress on the
+ // primary or on one of the secondaries to complete.
+ for (let dbName of primary.getDBNames()) {
if (dbName === "local") {
continue;
}
@@ -1170,28 +1154,25 @@ var ReplSetTest = function(opts) {
// skip view evaluation, and therefore won't fail on an invalid view.
if (!collInfo.name.startsWith('system.')) {
// 'usePowerOf2Sizes' is ignored by the server so no actual collection
- // modification takes place.
- assert.commandWorked(
- dbHandle.runCommand({collMod: collInfo.name, usePowerOf2Sizes: true}));
+ // modification takes place. We intentionally await replication without
+ // doing any I/O to avoid any overhead from allocating or deleting data
+ // files when using the MMAPv1 storage engine. We call awaitReplication()
+ // later on to ensure the collMod is replicated to all nodes.
+ assert.commandWorked(dbHandle.runCommand({
+ collMod: collInfo.name,
+ usePowerOf2Sizes: true,
+ }));
}
});
}
- let dummyDB = primary.getDB(uniqueDbName);
- let dummyColl = dummyDB.dummy;
- assert.writeOK(dummyColl.insert(
- {x: 1}, {writeConcern: {w: this.nodeList().length, wtimeout: self.kDefaultTimeoutMS}}));
-
- // We drop the dummy database for cleanup purposes only.
- assert.commandWorked(dummyDB.dropDatabase());
-
var activeException = false;
+ // Lock the primary to prevent the TTL monitor from deleting expired documents in
+ // the background while we are getting the dbhashes of the replica set members.
+ assert.commandWorked(primary.adminCommand({fsync: 1, lock: 1}),
+ 'failed to lock the primary');
try {
- // Lock the primary to prevent the TTL monitor from deleting expired documents in
- // the background while we are getting the dbhashes of the replica set members.
- assert.commandWorked(primary.adminCommand({fsync: 1, lock: 1}),
- 'failed to lock the primary');
this.awaitReplication(60 * 1000 * 5);
checkerFunction.apply(this, checkerFunctionArgs);
} catch (e) {