summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2018-11-28 23:19:56 -0500
committerBenety Goh <benety@mongodb.com>2018-11-28 23:19:56 -0500
commit41c44d02cf39ef581888bed68c547e4ed9b5a323 (patch)
treeeef10e598833c21ec66524cb9d52ed96043097d5 /jstests
parent03e13f90426a82a97cbb0f926385e09904519259 (diff)
downloadmongo-41c44d02cf39ef581888bed68c547e4ed9b5a323.tar.gz
SERVER-37729 background index builds on secondaries cannot be interrupted by killOp
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/indexbg_killop_apply_ops.js18
-rw-r--r--jstests/noPassthrough/indexbg_killop_secondary.js18
-rw-r--r--jstests/noPassthrough/indexbg_shutdown.js4
3 files changed, 14 insertions, 26 deletions
diff --git a/jstests/noPassthrough/indexbg_killop_apply_ops.js b/jstests/noPassthrough/indexbg_killop_apply_ops.js
index 6867efb1a23..093a6590a83 100644
--- a/jstests/noPassthrough/indexbg_killop_apply_ops.js
+++ b/jstests/noPassthrough/indexbg_killop_apply_ops.js
@@ -52,23 +52,19 @@
// When the index build starts, find its op id.
const opId = IndexBuildTest.waitForIndexBuildToStart(testDB);
- // Kill the index build.
+ // Kill the index build. This should have no effect.
assert.commandWorked(testDB.killOp(opId));
// Wait for the index build to stop.
- try {
- IndexBuildTest.waitForIndexBuildToStop(testDB);
- } finally {
- IndexBuildTest.resumeIndexBuilds(primary);
- }
+ IndexBuildTest.resumeIndexBuilds(primary);
+ IndexBuildTest.waitForIndexBuildToStop(testDB);
// Expect successful createIndex command invocation in parallel shell because applyOps returns
// immediately after starting the background index build in a separate thread.
createIdx();
- // Check that no new index has been created. This verifies that the index build was aborted
- // rather than successfully completed.
- IndexBuildTest.assertIndexes(coll, 1, ['_id_']);
+ // Check that index was created on the primary despite the attempted killOp().
+ IndexBuildTest.assertIndexes(coll, 2, ['_id_', 'a_1']);
// Check that a new index has been created on the secondary.
// This is due to the createIndexes command being replicated to the secondary before the primary
@@ -79,9 +75,5 @@
const secondaryColl = secondaryDB.getCollection(coll.getName());
IndexBuildTest.assertIndexes(secondaryColl, 2, ['_id_', 'a_1']);
- // Index 'a_1' was aborted on the primary, resulting in a different set of indexes on the
- // secondary compared to the primary. Therefore, we skip the dbhash checking while tearing down
- // the replica set test fixture.
- TestData.skipCheckDBHashes = true;
rst.stopSet();
})();
diff --git a/jstests/noPassthrough/indexbg_killop_secondary.js b/jstests/noPassthrough/indexbg_killop_secondary.js
index c3edfe831ee..2201d2714ac 100644
--- a/jstests/noPassthrough/indexbg_killop_secondary.js
+++ b/jstests/noPassthrough/indexbg_killop_secondary.js
@@ -38,29 +38,21 @@
const secondaryDB = secondary.getDB(testDB.getName());
const opId = IndexBuildTest.waitForIndexBuildToStart(secondaryDB);
- // Kill the index build.
+ // Kill the index build. This should have no effect.
assert.commandWorked(secondaryDB.killOp(opId));
// Wait for the index build to stop.
- try {
- IndexBuildTest.waitForIndexBuildToStop(secondaryDB);
- } finally {
- IndexBuildTest.resumeIndexBuilds(secondary);
- }
+ IndexBuildTest.resumeIndexBuilds(secondary);
+ IndexBuildTest.waitForIndexBuildToStop(secondaryDB);
// Expect successful createIndex command invocation in parallel shell. A new index should be
// present on the primary.
createIdx();
IndexBuildTest.assertIndexes(coll, 2, ['_id_', 'a_1']);
- // Check that no new index has been created on the secondary.
- // This verifies that the index build was aborted rather than successfully completed.
+ // Check that index was created on the secondary despite the attempted killOp().
const secondaryColl = secondaryDB.getCollection(coll.getName());
- IndexBuildTest.assertIndexes(secondaryColl, 1, ['_id_']);
+ IndexBuildTest.assertIndexes(secondaryColl, 2, ['_id_', 'a_1']);
- // Index 'a_1' was aborted on the secondary, resulting in a different set of indexes on the
- // secondary compared to the primary. Therefore, we skip the dbhash checking while tearing down
- // the replica set test fixture.
- TestData.skipCheckDBHashes = true;
rst.stopSet();
})();
diff --git a/jstests/noPassthrough/indexbg_shutdown.js b/jstests/noPassthrough/indexbg_shutdown.js
index 761e3e8bb8e..83fce5eb488 100644
--- a/jstests/noPassthrough/indexbg_shutdown.js
+++ b/jstests/noPassthrough/indexbg_shutdown.js
@@ -2,6 +2,7 @@
* Starts a replica set, builds an index in background,
* shuts down a secondary while it's building that index, and confirms that the secondary
* shuts down cleanly, without an fassert.
+ * Also confirms that killOp has no effect on the background index build on the secondary.
* @tags: [requires_replication]
*/
@@ -74,6 +75,9 @@
const opId = IndexBuildTest.waitForIndexBuildToStart(secondDB);
jsTestLog('Index builds started on secondary. Op ID of one of the builds: ' + opId);
+ // Kill the index build. This should have no effect.
+ assert.commandWorked(secondDB.killOp(opId));
+
jsTest.log("Restarting secondary to retry replication");
// Secondary should restart cleanly.