diff options
author | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2018-02-21 22:13:20 -0500 |
---|---|---|
committer | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2018-02-21 22:13:23 -0500 |
commit | 80b1a54a112b5853d0903ae424ffc5e3bb289077 (patch) | |
tree | 3b2cad4010d1deb12a7f91686f5437c48822c896 /jstests | |
parent | 3157be3048cdeb676579ed0d860d8416cb8c4667 (diff) | |
download | mongo-80b1a54a112b5853d0903ae424ffc5e3bb289077.tar.gz |
SERVER-33359: Allow RTT storage engines to manage indexes on rollback.
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/index_no_retry.js | 64 | ||||
-rw-r--r-- | jstests/noPassthrough/index_retry.js | 65 | ||||
-rw-r--r-- | jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js | 27 |
3 files changed, 21 insertions, 135 deletions
diff --git a/jstests/noPassthrough/index_no_retry.js b/jstests/noPassthrough/index_no_retry.js deleted file mode 100644 index 40442555760..00000000000 --- a/jstests/noPassthrough/index_no_retry.js +++ /dev/null @@ -1,64 +0,0 @@ -// Check index rebuild is disabled with --noIndexBuildRetry when MongoDB is killed. -// -// This test requires persistence beacuase it assumes data/indices will survive a restart. -// This test requires journaling because the information that an index build was started -// must be made durable when the process aborts. -// @tags: [requires_persistence, requires_journaling] -(function() { - 'use strict'; - var baseName = 'index_no_retry'; - var dbpath = MongoRunner.dataPath + baseName; - - var conn = MongoRunner.runMongod({dbpath: dbpath}); - assert.neq(null, conn, 'failed to start mongod'); - - var test = conn.getDB("test"); - - var name = 'jstests_slownightly_' + baseName; - var t = test.getCollection(name); - t.drop(); - - var bulk = t.initializeUnorderedBulkOp(); - for (var i = 0; i < 100; ++i) { - bulk.insert({a: i}); - } - - // Make sure the documents are journaled - assert.writeOK(bulk.execute({j: true})); - - assert.eq(100, t.count(), 'unexpected number of documents after bulk insert.'); - - function abortDuringIndexBuild(options) { - var createIdx = startParallelShell(function() { - var coll = db.getSiblingDB('test').getCollection('jstests_slownightly_index_no_retry'); - - // Fail point will handle journal flushing and killing the mongod - assert.commandWorked(db.adminCommand( - {configureFailPoint: 'crashAfterStartingIndexBuild', mode: 'alwaysOn'})); - coll.createIndex({a: 1}, {background: true}); - }, conn.port); - - var exitCode = createIdx({checkExitSuccess: false}); - assert.neq(0, exitCode, "expected shell to exit abnormally due to mongod being terminated"); - } - - abortDuringIndexBuild(); - - assert.eq(waitProgram(conn.pid), - MongoRunner.EXIT_TEST, - "mongod should have crashed due to the 'crashAfterStartingIndexBuild' " + - "failpoint being set."); - - conn = MongoRunner.runMongod({dbpath: dbpath, noIndexBuildRetry: '', restart: true}); - test = conn.getDB("test"); - t = test.getCollection(name); - - assert.throws(function() { - t.find({}, {_id: 0, a: 1}).hint({a: 1}).next(); - }, [], 'index {a: 1} was rebuilt in spite of --noIndexBuildRetry'); - - var indexes = t.getIndexes(); - assert.eq(1, indexes.length, 'unfinished indexes in listIndexes result: ' + tojson(indexes)); - - MongoRunner.stopMongod(conn); -}()); diff --git a/jstests/noPassthrough/index_retry.js b/jstests/noPassthrough/index_retry.js deleted file mode 100644 index f546c81ec38..00000000000 --- a/jstests/noPassthrough/index_retry.js +++ /dev/null @@ -1,65 +0,0 @@ -// Check index rebuild when MongoDB is killed. -// -// This test requires persistence because it assumes data/indices will survive a restart. -// This test requires journaling because the information that an index build was started -// must be made durable when the process aborts. -// @tags: [requires_persistence, requires_journaling] -(function() { - 'use strict'; - var baseName = 'index_retry'; - var dbpath = MongoRunner.dataPath + baseName; - - var conn = MongoRunner.runMongod({dbpath: dbpath}); - assert.neq(null, conn, 'failed to start mongod'); - - var test = conn.getDB("test"); - - var name = 'jstests_slownightly_' + baseName; - var t = test.getCollection(name); - t.drop(); - - var bulk = t.initializeUnorderedBulkOp(); - for (var i = 0; i < 100; ++i) { - bulk.insert({a: i}); - } - - // Make sure the documents are journaled - assert.writeOK(bulk.execute({j: true})); - - assert.eq(100, t.count(), 'unexpected number of documents after bulk insert.'); - - function abortDuringIndexBuild() { - var createIdx = startParallelShell(function() { - var coll = db.getSiblingDB('test').getCollection('jstests_slownightly_index_retry'); - - // Fail point will handle journal flushing and killing the mongod - assert.commandWorked(db.adminCommand( - {configureFailPoint: 'crashAfterStartingIndexBuild', mode: 'alwaysOn'})); - coll.createIndex({a: 1}, {background: true}); - }, conn.port); - - var exitCode = createIdx({checkExitSuccess: false}); - assert.neq(0, exitCode, "expected shell to exit abnormally due to mongod being terminated"); - } - - abortDuringIndexBuild(); - - assert.eq(waitProgram(conn.pid), - MongoRunner.EXIT_TEST, - "mongod should have crashed due to the 'crashAfterStartingIndexBuild' " + - "failpoint being set."); - - conn = MongoRunner.runMongod({dbpath: dbpath, restart: true}); - test = conn.getDB("test"); - t = test.getCollection(name); - - assert.eq(100, - t.find({}, {_id: 0, a: 1}).hint({a: 1}).itcount(), - 'index {a: 1} was expected to be rebuilt on startup'); - var indexes = t.getIndexes(); - assert.eq(2, - indexes.length, - 'unexpected number of indexes in listIndexes result: ' + tojson(indexes)); - - MongoRunner.stopMongod(conn); -}()); diff --git a/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js b/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js index f59a59e0070..97bcaff5412 100644 --- a/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js +++ b/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js @@ -1,20 +1,34 @@ /** - * Starts a replica set, builds an index in background. - * Kills the secondary with a failpoint once the index build starts. - * It should *not* build an index on the secondary on restart. + * Starts a replica set, builds an index in background. Kills the secondary with a failpoint once + * the index build starts. It should *not* build an index on the secondary on restart due to + * `--noIndexBuildRetry` option being supplied. */ // @tags: [requires_persistence, requires_journaling, requires_replication] (function() { 'use strict'; + // Assert that running `mongod` with `--noIndexBuildRetry` and `--replSet` does not startup. + { + // If code breaks the incompatibility between `--noIndexBuildRetry` and `--replSet`, using + // `notAStorageEngine` will cause a failure later in execution that returns a different + // exit code (100). + var process = MongoRunner.runMongod({ + noIndexBuildRetry: "", + replSet: "rs0", + storageEngine: "notAStorageEngine", + waitForConnect: false + }); + var exitCode = waitProgram(process.pid); + assert.eq(1, exitCode); + } + // Skip db hash check because secondary will have different number of indexes due to the // --noIndexBuildRetry command line option. TestData.skipCheckDBHashes = true; // Set up replica set. - var replTest = new ReplSetTest( - {name: 'bgIndexNoRetry', nodes: 3, nodeOptions: {noIndexBuildRetry: "", syncdelay: 1}}); + var replTest = new ReplSetTest({name: 'bgIndexNoRetry', nodes: 3}); var nodenames = replTest.nodeList(); var nodes = replTest.startSet(); @@ -61,7 +75,8 @@ // that the index can be rebuilt on startup and this test is only for the one triggered by (A). secondDB.adminCommand({fsync: 1}); replTest.stop(second, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL}); - replTest.start(second, {}, /*restart*/ true, /*wait=*/true); + replTest.start( + second, {"noReplSet": true, "noIndexBuildRetry": ""}, /*restart*/ true, /*wait=*/false); // Make sure secondary comes back. assert.soon(function() { |