summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2022-03-22 13:00:58 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-23 15:48:17 +0000
commit94d982e0a8615b705a653e0ac6eba88e1bf3c3f0 (patch)
treea3e8a76ba0e5d6e35d9306b139b786de7d6413d7
parentb422e6a280704b8f898d4c98b2576b1aa1e624e1 (diff)
downloadmongo-94d982e0a8615b705a653e0ac6eba88e1bf3c3f0.tar.gz
SERVER-64772 Don't finish index build before stepdown in index_killop_after_stepdown.js
(cherry picked from commit e28bd15569e1c3ec229a661c3f75f27806ee8b04)
-rw-r--r--jstests/noPassthrough/index_killop_after_stepdown.js81
1 files changed, 36 insertions, 45 deletions
diff --git a/jstests/noPassthrough/index_killop_after_stepdown.js b/jstests/noPassthrough/index_killop_after_stepdown.js
index ffccdc09813..8a4f20987ca 100644
--- a/jstests/noPassthrough/index_killop_after_stepdown.js
+++ b/jstests/noPassthrough/index_killop_after_stepdown.js
@@ -20,7 +20,7 @@ const rst = new ReplSetTest({
{},
]
});
-const nodes = rst.startSet();
+rst.startSet();
rst.initiate();
const primary = rst.getPrimary();
@@ -30,53 +30,44 @@ const coll = testDB.getCollection('test');
assert.commandWorked(coll.insert({a: 1}));
let res = assert.commandWorked(primary.adminCommand(
- {configureFailPoint: 'hangAfterInitializingIndexBuild', mode: 'alwaysOn'}));
-const hangAfterInitFailpointTimesEntered = res.count;
-
-res = assert.commandWorked(primary.adminCommand(
{configureFailPoint: 'hangBeforeIndexBuildAbortOnInterrupt', mode: 'alwaysOn'}));
const hangBeforeAbortFailpointTimesEntered = res.count;
-const createIdx = IndexBuildTest.startIndexBuild(primary, coll.getFullName(), {a: 1});
-
-try {
- assert.commandWorked(primary.adminCommand({
- waitForFailPoint: "hangAfterInitializingIndexBuild",
- timesEntered: hangAfterInitFailpointTimesEntered + 1,
- maxTimeMS: kDefaultWaitForFailPointTimeout
- }));
-
- // When the index build starts, find its op id. This will be the op id of the client
- // connection, not the thread pool task managed by IndexBuildsCoordinatorMongod.
- const filter = {"desc": {$regex: /conn.*/}};
- const opId = IndexBuildTest.waitForIndexBuildToStart(testDB, coll.getName(), 'a_1', filter);
-
- // Kill the index build.
- assert.commandWorked(testDB.killOp(opId));
-
- // Let the index build continue running.
- assert.commandWorked(
- primary.adminCommand({configureFailPoint: 'hangAfterInitializingIndexBuild', mode: 'off'}));
-
- // Wait for the command thread to abort the index build.
- assert.commandWorked(primary.adminCommand({
- waitForFailPoint: "hangBeforeIndexBuildAbortOnInterrupt",
- timesEntered: hangBeforeAbortFailpointTimesEntered + 1,
- maxTimeMS: kDefaultWaitForFailPointTimeout
- }));
-
- // Step down the primary, preventing the index build from generating an abort oplog entry.
- assert.commandWorked(testDB.adminCommand({replSetStepDown: 30, force: true}));
-} finally {
- assert.commandWorked(
- primary.adminCommand({configureFailPoint: 'hangAfterInitializingIndexBuild', mode: 'off'}));
- // Let the index build finish cleaning up.
- assert.commandWorked(primary.adminCommand(
- {configureFailPoint: 'hangBeforeIndexBuildAbortOnInterrupt', mode: 'off'}));
-}
-
-const exitCode = createIdx({checkExitSuccess: false});
-assert.neq(0, exitCode, 'expected shell to exit abnormally due to index build being terminated');
+IndexBuildTest.pauseIndexBuilds(primary);
+const createIdx = IndexBuildTest.startIndexBuild(
+ primary, coll.getFullName(), {a: 1}, {}, [ErrorCodes.Interrupted]);
+
+// When the index build starts, find its op id. This will be the op id of the client connection, not
+// the thread pool task managed by IndexBuildsCoordinatorMongod.
+const filter = {
+ "desc": {$regex: /conn.*/}
+};
+const opId = IndexBuildTest.waitForIndexBuildToStart(testDB, coll.getName(), 'a_1', filter);
+
+// Kill the index build.
+assert.commandWorked(testDB.killOp(opId));
+
+// Wait for the command thread to observe the killOp.
+assert.commandWorked(primary.adminCommand({
+ waitForFailPoint: "hangBeforeIndexBuildAbortOnInterrupt",
+ timesEntered: hangBeforeAbortFailpointTimesEntered + 1,
+ maxTimeMS: kDefaultWaitForFailPointTimeout
+}));
+
+// Step down the primary, preventing the index build from generating an abort oplog entry.
+assert.commandWorked(testDB.adminCommand({replSetStepDown: 30, force: true}));
+
+// Let the command thread try to abort the index build.
+assert.commandWorked(primary.adminCommand(
+ {configureFailPoint: 'hangBeforeIndexBuildAbortOnInterrupt', mode: 'off'}));
+
+// Unable to abort index build because we are not primary.
+checkLog.containsJson(primary, 20449);
+
+createIdx();
+
+// Let the index build continue running.
+IndexBuildTest.resumeIndexBuilds(primary);
// Wait for the index build to stop.
IndexBuildTest.waitForIndexBuildToStop(testDB);