diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-07-20 14:34:38 -0400 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-07-20 14:34:38 -0400 |
commit | d7815ffb10e600cc076ea8f6646b9ca7dcf4dca5 (patch) | |
tree | c2a2d2e92c6a189e96fe9519df1fe4a40f95c2a6 /jstests/hooks | |
parent | 48abdc3093889286a947f9aba16342cfbb82efaa (diff) | |
download | mongo-d7815ffb10e600cc076ea8f6646b9ca7dcf4dca5.tar.gz |
SERVER-25146 JS replset dbhash hook fails when checking nindexes with a collection containing a background index
Diffstat (limited to 'jstests/hooks')
-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..0cece1b037b 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.nodes.length, wtimeout: 5 * 60 * 1000}})); + var activeException = false; try { |