diff options
author | James Wahlin <james.wahlin@10gen.com> | 2016-10-17 12:47:38 -0400 |
---|---|---|
committer | James Wahlin <james.wahlin@10gen.com> | 2016-10-17 12:53:29 -0400 |
commit | b11e97b8a85e2f3c2c29430884bb5d93bfc8da52 (patch) | |
tree | 0b9e79b89ae0222e030f16f856f6a5dc4f9f4a59 /src | |
parent | c66e3f224205ff00ec67b63a081fc7ce980e5855 (diff) | |
download | mongo-b11e97b8a85e2f3c2c29430884bb5d93bfc8da52.tar.gz |
SERVER-26435 Fix replsettest check for background index build
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/shell/replsettest.js | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index 30e6a4cc850..3b0acbd5626 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -885,20 +885,40 @@ 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-25176), + // Since we cannot determine if there is a background index in progress (SERVER-26624), // we flush indexing as follows: - // 1. Create a foreground index on a dummy collection/database - // 2. Insert a document into the dummy collection with a writeConcern for all nodes - // 3. Drop the dummy database - var dbNames = new Set(primary.getDBNames()); - var uniqueDbName = generateUniqueDbName(dbNames, "flush_all_background_indexes_"); - - var dummyDB = primary.getDB(uniqueDbName); - var dummyColl = dummyDB.dummy; - dummyColl.drop(); - assert.commandWorked(dummyColl.createIndex({x: 1})); + // 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()) { + if (dbName === "local") { + continue; + } + + let dbHandle = primary.getDB(dbName); + dbHandle + .getCollectionInfos({ + $or: [{type: "collection"}, {type: {$exists: false}}], + name: {$not: /^system\./} + }) + .forEach(function(collInfo) { + // 'usePowerOf2Sizes' is ignored by the server so no actual collection + // modification takes place. + 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; |