summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-01-24 13:16:09 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-01-24 22:05:47 +0000
commita7aecc1ff0af7822c38b5f5da2bc0fd27e3f7778 (patch)
treeb901e1f34aab5853e6245576b36044532fc45904
parente4f034d162874b1ab3a258942a468d844d1b1fcc (diff)
downloadmongo-a7aecc1ff0af7822c38b5f5da2bc0fd27e3f7778.tar.gz
SERVER-45681 fix list_indexes_with_build_uuids.js to work with storage engine without snapshot read support
-rw-r--r--jstests/noPassthrough/list_indexes_with_build_uuids.js25
1 files changed, 19 insertions, 6 deletions
diff --git a/jstests/noPassthrough/list_indexes_with_build_uuids.js b/jstests/noPassthrough/list_indexes_with_build_uuids.js
index b1a95b5dbd6..34c4c4cb3ab 100644
--- a/jstests/noPassthrough/list_indexes_with_build_uuids.js
+++ b/jstests/noPassthrough/list_indexes_with_build_uuids.js
@@ -57,11 +57,20 @@ replSet.waitForAllIndexBuildsToFinish(dbName, collName);
// Start hanging index builds on the secondary.
IndexBuildTest.pauseIndexBuilds(secondary);
-// Build and hang on the second index.
-assert.commandWorked(primaryDB.runCommand({
- createIndexes: collName,
- indexes: [{key: {j: 1}, name: secondIndexName, background: true}],
-}));
+// With storage engines that do not support snapshot reads, the commitIndexBuild oplog entry may
+// block the listIndexes command on the secondary during oplog application because it will hold the
+// PBWM while waiting for the index build to complete in the backgroud. Therefore, we get the
+// primary to hold off on writing the commitIndexBuild oplog entry until we are ready to resume
+// index builds on the secondary.
+if (IndexBuildTest.supportsTwoPhaseIndexBuild(primary)) {
+ IndexBuildTest.pauseIndexBuilds(primary);
+}
+
+// Build and hang on the second index. This should be run in the background if we pause index
+// builds on the primary because the createIndexes command will block.
+const coll = primaryDB.getCollection(collName);
+const createIdx =
+ IndexBuildTest.startIndexBuild(primary, coll.getFullName(), {j: 1}, {name: secondIndexName});
// Wait for index builds to start on the secondary.
const opId = IndexBuildTest.waitForIndexBuildToStart(secondaryDB);
@@ -81,8 +90,12 @@ assert.eq(indexes[1].name, "first");
assert.eq(indexes[2].spec.name, "second");
assert(indexes[2].hasOwnProperty("buildUUID"));
-// Allow the secondary to finish the index build.
+// Allow the replica set to finish the index build.
IndexBuildTest.resumeIndexBuilds(secondary);
+// Wait for the index build to complete on the primary if we paused it.
+IndexBuildTest.resumeIndexBuilds(primary);
+createIdx();
+
replSet.stopSet();
}());