summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2016-09-09 17:48:35 -0400
committerMathias Stearn <mathias@10gen.com>2016-09-16 16:52:29 -0400
commitdc83fb0433fcae6e72f035df7458473b59223eb5 (patch)
tree9ec4d2f312f565cea234e3323dad17872e451522 /jstests/noPassthroughWithMongod
parent446c059c3086dcb579816d29b8e1b43da13e8dbb (diff)
downloadmongo-dc83fb0433fcae6e72f035df7458473b59223eb5.tar.gz
SERVER-26016 Add a basic test of oplog replay on startup
Fixes a small but important bug in SERVER-7200.
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r--jstests/noPassthroughWithMongod/indexbg_restart_secondary.js18
-rw-r--r--jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js18
2 files changed, 18 insertions, 18 deletions
diff --git a/jstests/noPassthroughWithMongod/indexbg_restart_secondary.js b/jstests/noPassthroughWithMongod/indexbg_restart_secondary.js
index 55c13f3e44e..a84e2b57293 100644
--- a/jstests/noPassthroughWithMongod/indexbg_restart_secondary.js
+++ b/jstests/noPassthroughWithMongod/indexbg_restart_secondary.js
@@ -49,18 +49,18 @@
replTest.awaitReplication();
assert.commandWorked(secondDB.adminCommand(
- {configureFailPoint: 'crashAfterStartingIndexBuild', mode: 'alwaysOn'}));
+ {configureFailPoint: 'hangAfterStartingIndexBuildUnlocked', mode: 'alwaysOn'}));
coll.createIndex({i: 1}, {background: true});
+ masterDB.getLastError(2);
assert.eq(2, coll.getIndexes().length);
- assert.eq(waitProgram(second.pid),
- MongoRunner.EXIT_TEST,
- "secondary should have crashed due to the 'crashAfterStartingIndexBuild' " +
- "failpoint being set.");
-
- // Restart the secondary. Not using the restart() function here
- // since the server is already killed by the fail point.
- replTest.start(secondId, {}, /*restart=*/true, /*wait=*/true);
+ // Kill -9 and restart the secondary, after making sure all writes are durable.
+ // Waiting for durable is important for both (A) the record that we started the index build so
+ // it is rebuild on restart, and (B) the update to minvalid to show that we've already applied
+ // the oplog entry so it isn't replayed. If (A) is present without (B), then there are two ways
+ // that the index can be rebuilt on startup and this test is only for the one triggered by (A).
+ secondDB.adminCommand({fsync: 1});
+ replTest.restart(secondId, {}, /*signal=*/9, /*wait=*/true);
// Make sure secondary comes back.
assert.soon(function() {
diff --git a/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js b/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js
index bfeb44dcfeb..747c8b2e6b8 100644
--- a/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js
+++ b/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js
@@ -47,18 +47,18 @@
replTest.awaitReplication();
assert.commandWorked(secondDB.adminCommand(
- {configureFailPoint: 'crashAfterStartingIndexBuild', mode: 'alwaysOn'}));
+ {configureFailPoint: 'hangAfterStartingIndexBuildUnlocked', mode: 'alwaysOn'}));
masterColl.createIndex({i: 1}, {background: true});
+ masterDB.getLastError(2);
assert.eq(2, masterColl.getIndexes().length);
- assert.eq(waitProgram(second.pid),
- MongoRunner.EXIT_TEST,
- "secondary should have crashed due to the 'crashAfterStartingIndexBuild' " +
- "failpoint being set.");
-
- // Restart the secondary. Not using the restart() function here
- // since the server is already killed by the fail point.
- replTest.start(secondId, {}, /*restart=*/true, /*wait=*/true);
+ // Kill -9 and restart the secondary, after making sure all writes are durable.
+ // Waiting for durable is important for both (A) the record that we started the index build so
+ // it is rebuild on restart, and (B) the update to minvalid to show that we've already applied
+ // the oplog entry so it isn't replayed. If (A) is present without (B), then there are two ways
+ // that the index can be rebuilt on startup and this test is only for the one triggered by (A).
+ secondDB.adminCommand({fsync: 1});
+ replTest.restart(secondId, {}, /*signal=*/9, /*wait=*/true);
// Make sure secondary comes back.
assert.soon(function() {