diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-07-22 09:12:17 -0400 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-07-22 09:12:17 -0400 |
commit | cf6668e6458f47b15414e2623519612612ce6ba4 (patch) | |
tree | dbd789032afae14790bc0c54310973b7a80c8268 | |
parent | ea026e685bc90c102e2305e21b8bdc096475b49b (diff) | |
download | mongo-cf6668e6458f47b15414e2623519612612ce6ba4.tar.gz |
SERVER-25146 JS replset dbhash hook fails when checking nindexes with a collection containing a background index
-rw-r--r-- | jstests/hooks/check_repl_dbhash.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/jstests/hooks/check_repl_dbhash.js b/jstests/hooks/check_repl_dbhash.js index 76504d4a1f8..65896eace78 100644 --- a/jstests/hooks/check_repl_dbhash.js +++ b/jstests/hooks/check_repl_dbhash.js @@ -80,6 +80,29 @@ function checkDBHashesFsyncLocked(rst) { var primary = rst.getPrimary(); assert(primary, 'calling getPrimary() failed'); + function generateUniqueDbName(dbNameSet, prefix) { + var uniqueDbName; + Random.setRandomSeed(); + do { + uniqueDbName = prefix + Random.randInt(100000); + } while (dbNameSet.has(uniqueDbName)); + return uniqueDbName; + } + + // Since we cannot determine if there is a background index in progress (SERVER-25176), + // we flush indexing as follows: + // 1. Drop a dummy collection + // 2. Create a foreground index on the dummy collection + // 3. Insert a document into the dummy collection with a writeConcern for all nodes + var dbNames = new Set(primary.getDBNames()); + var uniqueDbName = generateUniqueDbName(dbNames, "flush_all_background_indexes_"); + + var dummyColl = primary.getDB(uniqueDbName).dummy; + dummyColl.drop(); + assert.commandWorked(dummyColl.createIndex({x: 1})); + assert.writeOK(dummyColl.insert( + {x: 1}, {writeConcern: {w: rst.nodeList().length, wtimeout: 5 * 60 * 1000}})); + var activeException = false; try { |