diff options
author | William Schultz <william.schultz@mongodb.com> | 2017-12-07 15:39:36 -0500 |
---|---|---|
committer | William Schultz <william.schultz@mongodb.com> | 2017-12-07 15:39:54 -0500 |
commit | 09da9900b81ac80a422747f934ccc08813590d63 (patch) | |
tree | d9f3092eeb9ed9710ae3d75274440b51c57055f9 /jstests/replsets | |
parent | 51b699b02a5858a115a95af206253104c46e4bb0 (diff) | |
download | mongo-09da9900b81ac80a422747f934ccc08813590d63.tar.gz |
SERVER-32193 Remove test coverage of rollbackViaRefetchNoUUID
Diffstat (limited to 'jstests/replsets')
8 files changed, 0 insertions, 834 deletions
diff --git a/jstests/replsets/rollback_refetch_no_uuid/README.md b/jstests/replsets/rollback_refetch_no_uuid/README.md deleted file mode 100644 index 47361857203..00000000000 --- a/jstests/replsets/rollback_refetch_no_uuid/README.md +++ /dev/null @@ -1,19 +0,0 @@ -The tests in this directory are rollback tests that existed in 3.4 and are intended to succeed using -the older `rollbackViaRefetchNoUUID` algorithm. The newer rollback algorithm, `rollbackViaRefetch`, -introduced in 3.6, adds the ability to roll back a wider range of operations, but the -`rollbackViaRefetchNoUUID` algorithm was maintained for multi-version replica set support. The older -`rollbackViaRefetchNoUUID` algorithm should provide guarantees no worse than the 3.4 rollback -algorithm, so we keep these old tests around to run only with that algorithm. They represent a -snapshot of 3.4 rollback tests that are related to rollback of specific operations or operation -sequences. Newer tests have been added in the main `jstests/replsets` directory that fully exercise -the `rollbackViaRefetch` algorithm, but some of those tests exercise functionality that the older -algorithm does not support. So, we maintain these tests to provide the basic assurance that the -`rollbackViaRefetchNoUUID` algorithm does not regress at all from the 3.4 rollback algorithm. - -Some rollback tests that exercise general, topological scenarios exist in the main -`jstests/replsets` directory, and will be run on both algorithms, since they shouldn't depend on a -rollback method's support of specific operation types. - -This suite of tests runs on the `replica_sets_rollback_refetch_no_uuid` suite. This suite, and this -sub-directory of tests, can be deleted in 3.8, when the `rollbackViaRefetchNoUUID` algorithm will no -longer be needed. See SERVER-29766. diff --git a/jstests/replsets/rollback_refetch_no_uuid/rollback.js b/jstests/replsets/rollback_refetch_no_uuid/rollback.js deleted file mode 100644 index a55f6da1c77..00000000000 --- a/jstests/replsets/rollback_refetch_no_uuid/rollback.js +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Basic test of successful rollback in replica sets. - * - * This test sets up a 3-node set, with an arbiter and 2 data-bearing nodes, A and B. - * A is the initial primary node. - * - * The test inserts 3 documents into A, and waits for them to replicate to B. Then, it partitions A - * from the other nodes, causing it to step down and causing B to be elected primary. - * - * Next, 3 more documents inserted into B, and B is partitioned from the arbiter. - * - * Next, A is allowed to connect to the arbiter again, and gets reelected primary. Because the - * arbiter doesn't know about the writes that B accepted, A becomes primary and we insert 3 new - * documents. Now, A and B have diverged. We heal the remaining network partition, bringing B back - * into the network. - * - * Finally, we expect either A or B to roll back its 3 divergent documents and acquire the other - * node's. - */ -load("jstests/replsets/rslib.js"); - -(function() { - "use strict"; - // helper function for verifying contents at the end of the test - var checkFinalResults = function(db) { - var x = db.bar.find().sort({q: 1}).toArray(); - assert.eq(5, x.length, "incorrect number of documents found. Docs found: " + tojson(x)); - assert.eq(1, x[0].q); - assert.eq(2, x[1].q); - assert.eq(3, x[2].q); - assert.eq(7, x[3].q); - assert.eq(8, x[4].q); - }; - - var replTest = new ReplSetTest({name: 'unicomplex', nodes: 3, oplogSize: 1, useBridge: true}); - var nodes = replTest.nodeList(); - - var conns = replTest.startSet(); - var r = replTest.initiate({ - "_id": "unicomplex", - "members": [ - {"_id": 0, "host": nodes[0], "priority": 3}, - {"_id": 1, "host": nodes[1]}, - {"_id": 2, "host": nodes[2], arbiterOnly: true} - ] - }); - - // Make sure we have a master - replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY); - var master = replTest.getPrimary(); - var a_conn = conns[0]; - var A = a_conn.getDB("admin"); - var b_conn = conns[1]; - a_conn.setSlaveOk(); - b_conn.setSlaveOk(); - var B = b_conn.getDB("admin"); - assert(master == conns[0], "conns[0] assumed to be master"); - assert(a_conn == master); - - // Wait for initial replication - var a = a_conn.getDB("foo"); - var b = b_conn.getDB("foo"); - - /* force the oplog to roll */ - if (new Date() % 2 == 0) { - jsTest.log("ROLLING OPLOG AS PART OF TEST (we only do this sometimes)"); - var pass = 1; - var first = a.getSisterDB("local").oplog.rs.find().sort({$natural: 1}).limit(1)[0]; - a.roll.insert({x: 1}); - while (1) { - var bulk = a.roll.initializeUnorderedBulkOp(); - for (var i = 0; i < 1000; i++) { - bulk.find({}).update({$inc: {x: 1}}); - } - // unlikely secondary isn't keeping up, but let's avoid possible intermittent - // issues with that. - assert.writeOK(bulk.execute({w: 2})); - - var op = a.getSisterDB("local").oplog.rs.find().sort({$natural: 1}).limit(1)[0]; - if (tojson(op.h) != tojson(first.h)) { - printjson(op); - printjson(first); - break; - } - pass++; - } - jsTest.log("PASSES FOR OPLOG ROLL: " + pass); - } else { - jsTest.log("NO ROLL"); - } - - assert.writeOK(a.bar.insert({q: 1, a: "foo"})); - assert.writeOK(a.bar.insert({q: 2, a: "foo", x: 1})); - assert.writeOK(a.bar.insert({q: 3, bb: 9, a: "foo"}, {writeConcern: {w: 2}})); - - assert.eq(a.bar.find().itcount(), 3, "a.count"); - assert.eq(b.bar.find().itcount(), 3, "b.count"); - - conns[0].disconnect(conns[1]); - conns[0].disconnect(conns[2]); - - // Wait for election and drain mode to finish on node 1. - assert.soon(function() { - try { - return B.isMaster().ismaster; - } catch (e) { - return false; - } - }, "didn't see a new master", 60000); - - // These 97 documents will be rolled back eventually. - for (var i = 4; i <= 100; i++) { - assert.writeOK(b.bar.insert({q: i})); - } - assert.eq(100, b.bar.find().itcount(), "u.count"); - - // a should not have the new data as it was partitioned. - conns[1].disconnect(conns[2]); - jsTest.log("*************** wait for server to reconnect ****************"); - conns[0].reconnect(conns[2]); - - jsTest.log("*************** B ****************"); - assert.soon(function() { - try { - return !B.isMaster().ismaster; - } catch (e) { - return false; - } - }); - jsTest.log("*************** A ****************"); - assert.soon(function() { - try { - return A.isMaster().ismaster; - } catch (e) { - return false; - } - }); - - assert.eq(3, a.bar.find().itcount(), "t is 3"); - assert.writeOK(a.bar.insert({q: 7})); - assert.writeOK(a.bar.insert({q: 8})); - - // A is 1 2 3 7 8 - // B is 1 2 3 4 5 6 ... 100 - - var connectionsCreatedOnPrimaryBeforeRollback = a.serverStatus().connections.totalCreated; - // bring B back online - conns[0].reconnect(conns[1]); - conns[1].reconnect(conns[2]); - - awaitOpTime(b_conn, a_conn); - replTest.awaitSecondaryNodes(); - replTest.awaitReplication(); - checkFinalResults(a); - checkFinalResults(b); - - var connectionsCreatedOnPrimaryAfterRollback = a.serverStatus().connections.totalCreated; - var connectionsCreatedOnPrimaryDuringRollback = - connectionsCreatedOnPrimaryAfterRollback - connectionsCreatedOnPrimaryBeforeRollback; - jsTest.log('connections created during rollback = ' + - connectionsCreatedOnPrimaryDuringRollback); - assert.lt(connectionsCreatedOnPrimaryDuringRollback, - 50, - 'excessive number of connections made by secondary to primary during rollback'); - - replTest.stopSet(15); -}()); diff --git a/jstests/replsets/rollback_refetch_no_uuid/rollback2.js b/jstests/replsets/rollback_refetch_no_uuid/rollback2.js deleted file mode 100644 index 5f26e542c59..00000000000 --- a/jstests/replsets/rollback_refetch_no_uuid/rollback2.js +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Basic test of a succesful replica set rollback for CRUD operations. - * - * This tests sets up a 3 node set, data-bearing nodes A and B and an arbiter. - * - * 1. A is elected PRIMARY and receives several writes, which are propagated to B. - * 2. A is isolated from the rest of the set and B is elected PRIMARY. - * 3. B receives several operations, which will later be undone during rollback. - * 4. B is then isolated and A regains its connection to the arbiter. - * 5. A receives many new operations, which B will replicate after rollback. - * 6. B rejoins the set and goes through the rollback process. - * 7. The contents of A and B are compare to ensure the rollback results in consistent nodes. - */ -load("jstests/replsets/rslib.js"); - -(function() { - "use strict"; - // helper function for verifying contents at the end of the test - var checkFinalResults = function(db) { - assert.eq(0, db.bar.count({q: 70})); - assert.eq(2, db.bar.count({q: 40})); - assert.eq(3, db.bar.count({a: "foo"})); - assert.eq(6, db.bar.count({q: {$gt: -1}})); - assert.eq(1, db.bar.count({txt: "foo"})); - assert.eq(33, db.bar.findOne({q: 0})["y"]); - assert.eq(1, db.kap.find().itcount()); - assert.eq(0, db.kap2.find().itcount()); - }; - - var name = "rollback2js"; - var replTest = new ReplSetTest({name: name, nodes: 3, useBridge: true}); - var nodes = replTest.nodeList(); - - var conns = replTest.startSet(); - replTest.initiate({ - "_id": name, - "members": [ - {"_id": 0, "host": nodes[0], priority: 3}, - {"_id": 1, "host": nodes[1]}, - {"_id": 2, "host": nodes[2], arbiterOnly: true} - ] - }); - - // Make sure we have a master and that that master is node A - replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY); - var master = replTest.getPrimary(); - var a_conn = conns[0]; - a_conn.setSlaveOk(); - var A = a_conn.getDB("admin"); - var b_conn = conns[1]; - b_conn.setSlaveOk(); - var B = b_conn.getDB("admin"); - assert.eq(master, conns[0], "conns[0] assumed to be master"); - assert.eq(a_conn, master); - - // Wait for initial replication - var a = a_conn.getDB("foo"); - var b = b_conn.getDB("foo"); - - // initial data for both nodes - assert.writeOK(a.bar.insert({q: 0})); - assert.writeOK(a.bar.insert({q: 1, a: "foo"})); - assert.writeOK(a.bar.insert({q: 2, a: "foo", x: 1})); - assert.writeOK(a.bar.insert({q: 3, bb: 9, a: "foo"})); - assert.writeOK(a.bar.insert({q: 40, a: 1})); - assert.writeOK(a.bar.insert({q: 40, a: 2})); - assert.writeOK(a.bar.insert({q: 70, txt: 'willremove'})); - a.createCollection("kap", {capped: true, size: 5000}); - assert.writeOK(a.kap.insert({foo: 1})); - // going back to empty on capped is a special case and must be tested - a.createCollection("kap2", {capped: true, size: 5501}); - replTest.awaitReplication(); - - var timeout; - if (replTest.getReplSetConfigFromNode().protocolVersion == 1) { - timeout = 30 * 1000; - } else { - timeout = 60 * 1000; - } - // isolate A and wait for B to become master - conns[0].disconnect(conns[1]); - conns[0].disconnect(conns[2]); - assert.soon(function() { - try { - return B.isMaster().ismaster; - } catch (e) { - return false; - } - }, "node B did not become master as expected", timeout); - - // do operations on B and B alone, these will be rolled back - assert.writeOK(b.bar.insert({q: 4})); - assert.writeOK(b.bar.update({q: 3}, {q: 3, rb: true})); - assert.writeOK(b.bar.remove({q: 40})); // multi remove test - assert.writeOK(b.bar.update({q: 2}, {q: 39, rb: true})); - // rolling back a delete will involve reinserting the item(s) - assert.writeOK(b.bar.remove({q: 1})); - assert.writeOK(b.bar.update({q: 0}, {$inc: {y: 1}})); - assert.writeOK(b.kap.insert({foo: 2})); - assert.writeOK(b.kap2.insert({foo: 2})); - // create a collection (need to roll back the whole thing) - assert.writeOK(b.newcoll.insert({a: true})); - // create a new empty collection (need to roll back the whole thing) - b.createCollection("abc"); - - // isolate B, bring A back into contact with the arbiter, then wait for A to become master - // insert new data into A so that B will need to rollback when it reconnects to A - conns[1].disconnect(conns[2]); - assert.soon(function() { - try { - return !B.isMaster().ismaster; - } catch (e) { - return false; - } - }); - - conns[0].reconnect(conns[2]); - assert.soon(function() { - try { - return A.isMaster().ismaster; - } catch (e) { - return false; - } - }); - assert.gte(a.bar.find().itcount(), 1, "count check"); - assert.writeOK(a.bar.insert({txt: 'foo'})); - assert.writeOK(a.bar.remove({q: 70})); - assert.writeOK(a.bar.update({q: 0}, {$inc: {y: 33}})); - - // A is 1 2 3 7 8 - // B is 1 2 3 4 5 6 - // put B back in contact with A and arbiter, as A is primary, B will rollback and then catch up - conns[1].reconnect(conns[2]); - conns[0].reconnect(conns[1]); - - awaitOpTime(b_conn, a_conn); - - // await steady state and ensure the two nodes have the same contents - replTest.awaitSecondaryNodes(); - replTest.awaitReplication(); - checkFinalResults(a); - checkFinalResults(b); - - replTest.stopSet(15); -}()); diff --git a/jstests/replsets/rollback_refetch_no_uuid/rollback3.js b/jstests/replsets/rollback_refetch_no_uuid/rollback3.js deleted file mode 100644 index bf987d9d143..00000000000 --- a/jstests/replsets/rollback_refetch_no_uuid/rollback3.js +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Basic test of a succesful replica set rollback for DDL operations. - * - * This tests sets up a 3 node set, data-bearing nodes A and B and an arbiter. - * - * 1. A is elected PRIMARY and receives several writes, which are propagated to B. - * 2. A is isolated from the rest of the set and B is elected PRIMARY. - * 3. B receives several operations, which will later be undone during rollback. - * 4. B is then isolated and A regains its connection to the arbiter. - * 5. A receives many new operations, which B will replicate after rollback. - * 6. B rejoins the set and goes through the rollback process. - * 7. The contents of A and B are compare to ensure the rollback results in consistent nodes. - */ -load("jstests/replsets/rslib.js"); - -(function() { - "use strict"; - // helper function for verifying contents at the end of the test - var checkFinalResults = function(db) { - assert.eq(2, db.b.getIndexes().length); - assert.eq(2, db.oldname.getIndexes().length); - assert.eq(2, db.oldname.find().itcount()); - assert.eq(1, db.kap.find().itcount()); - assert(db.kap.isCapped()); - assert.eq(0, db.bar.count({q: 70})); - assert.eq(33, db.bar.findOne({q: 0})["y"]); - assert.eq(0, db.bar.count({q: 70})); - assert.eq(1, db.bar.count({txt: "foo"})); - assert.eq(200, db.bar.count({i: {$gt: -1}})); - assert.eq(6, db.bar.count({q: {$gt: -1}})); - assert.eq(0, db.getSiblingDB("abc").foo.find().itcount()); - assert.eq(0, db.getSiblingDB("abc").bar.find().itcount()); - }; - - var name = "rollback2js"; - var replTest = new ReplSetTest({name: name, nodes: 3, useBridge: true}); - var nodes = replTest.nodeList(); - - var conns = replTest.startSet(); - replTest.initiate({ - "_id": name, - "members": [ - {"_id": 0, "host": nodes[0], priority: 3}, - {"_id": 1, "host": nodes[1]}, - {"_id": 2, "host": nodes[2], arbiterOnly: true} - ] - }); - - // Make sure we have a master and that that master is node A - replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY); - var master = replTest.getPrimary(); - var a_conn = conns[0]; - a_conn.setSlaveOk(); - var A = a_conn.getDB("admin"); - var b_conn = conns[1]; - b_conn.setSlaveOk(); - var B = b_conn.getDB("admin"); - assert.eq(master, conns[0], "conns[0] assumed to be master"); - assert.eq(a_conn, master); - - // Wait for initial replication - var a = a_conn.getDB("foo"); - var b = b_conn.getDB("foo"); - - // initial data for both nodes - assert.writeOK(a.b.insert({x: 1})); - a.b.ensureIndex({x: 1}); - assert.writeOK(a.oldname.insert({y: 1})); - assert.writeOK(a.oldname.insert({y: 2})); - a.oldname.ensureIndex({y: 1}, true); - assert.writeOK(a.bar.insert({q: 0})); - assert.writeOK(a.bar.insert({q: 1, a: "foo"})); - assert.writeOK(a.bar.insert({q: 2, a: "foo", x: 1})); - assert.writeOK(a.bar.insert({q: 3, bb: 9, a: "foo"})); - assert.writeOK(a.bar.insert({q: 40333333, a: 1})); - for (var i = 0; i < 200; i++) { - assert.writeOK(a.bar.insert({i: i})); - } - assert.writeOK(a.bar.insert({q: 40, a: 2})); - assert.writeOK(a.bar.insert({q: 70, txt: 'willremove'})); - a.createCollection("kap", {capped: true, size: 5000}); - assert.writeOK(a.kap.insert({foo: 1})); - replTest.awaitReplication(); - - // isolate A and wait for B to become master - conns[0].disconnect(conns[1]); - conns[0].disconnect(conns[2]); - assert.soon(function() { - try { - return B.isMaster().ismaster; - } catch (e) { - return false; - } - }); - - // do operations on B and B alone, these will be rolled back - assert.writeOK(b.bar.insert({q: 4})); - assert.writeOK(b.bar.update({q: 3}, {q: 3, rb: true})); - assert.writeOK(b.bar.remove({q: 40})); // multi remove test - assert.writeOK(b.bar.update({q: 2}, {q: 39, rb: true})); - // rolling back a delete will involve reinserting the item(s) - assert.writeOK(b.bar.remove({q: 1})); - assert.writeOK(b.bar.update({q: 0}, {$inc: {y: 1}})); - assert.writeOK(b.kap.insert({foo: 2})); - assert.writeOK(b.kap2.insert({foo: 2})); - // create a collection (need to roll back the whole thing) - assert.writeOK(b.newcoll.insert({a: true})); - // create a new empty collection (need to roll back the whole thing) - b.createCollection("abc"); - // drop a collection - we'll need all its data back! - b.bar.drop(); - // drop an index - verify it comes back - b.b.dropIndexes(); - // two to see if we transitively rollback? - b.oldname.renameCollection("newname"); - b.newname.renameCollection("fooname"); - assert(b.fooname.find().itcount() > 0, "count rename"); - // create an index - verify that it is removed - b.fooname.ensureIndex({q: 1}); - // test roll back (drop) a whole database - var abc = b.getSisterDB("abc"); - assert.writeOK(abc.foo.insert({x: 1})); - assert.writeOK(abc.bar.insert({y: 999})); - - // isolate B, bring A back into contact with the arbiter, then wait for A to become master - // insert new data into A so that B will need to rollback when it reconnects to A - conns[1].disconnect(conns[2]); - assert.soon(function() { - try { - return !B.isMaster().ismaster; - } catch (e) { - return false; - } - }); - - conns[0].reconnect(conns[2]); - assert.soon(function() { - try { - return A.isMaster().ismaster; - } catch (e) { - return false; - } - }); - assert(a.bar.find().itcount() >= 1, "count check"); - assert.writeOK(a.bar.insert({txt: 'foo'})); - assert.writeOK(a.bar.remove({q: 70})); - assert.writeOK(a.bar.update({q: 0}, {$inc: {y: 33}})); - - // A is 1 2 3 7 8 - // B is 1 2 3 4 5 6 - // put B back in contact with A and arbiter, as A is primary, B will rollback and then catch up - conns[1].reconnect(conns[2]); - conns[0].reconnect(conns[1]); - - awaitOpTime(b_conn, a_conn); - - // await steady state and ensure the two nodes have the same contents - replTest.awaitSecondaryNodes(); - replTest.awaitReplication(); - checkFinalResults(a); - checkFinalResults(b); - - replTest.stopSet(15); -}()); diff --git a/jstests/replsets/rollback_refetch_no_uuid/rollback_cmd_unrollbackable.js b/jstests/replsets/rollback_refetch_no_uuid/rollback_cmd_unrollbackable.js deleted file mode 100644 index f544520e686..00000000000 --- a/jstests/replsets/rollback_refetch_no_uuid/rollback_cmd_unrollbackable.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Test that a rollback of a non-rollbackable command causes a message to be logged - * - * If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will - * not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a - * scenario, none of the members will have any data, and upon restart will each look for a member to - * initial sync from, so no primary will be elected. This test induces such a scenario, so cannot be - * run on ephemeral storage engines. - * @tags: [requires_persistence] -*/ - -// Sets up a replica set and grabs things for later. -var name = "rollback_cmd_unrollbackable"; -var replTest = new ReplSetTest({name: name, nodes: 3}); -var nodes = replTest.nodeList(); -var conns = replTest.startSet(); -replTest.initiate({ - "_id": name, - "members": [ - {"_id": 0, "host": nodes[0], priority: 3}, - {"_id": 1, "host": nodes[1]}, - {"_id": 2, "host": nodes[2], arbiterOnly: true} - ] -}); -var a_conn = conns[0]; -var b_conn = conns[1]; -var AID = replTest.getNodeId(a_conn); -var BID = replTest.getNodeId(b_conn); - -// Gets master and do an initial write. -replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY); -var master = replTest.getPrimary(); -assert(master === conns[0], "conns[0] assumed to be master"); -assert(a_conn.host === master.host, "a_conn assumed to be master"); -var options = {writeConcern: {w: 2, wtimeout: ReplSetTest.kDefaultTimeoutMS}, upsert: true}; -assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options)); - -// Shuts down the master. -replTest.stop(AID); - -// Inserts a fake oplog entry with a non-rollbackworthy command. -master = replTest.getPrimary(); -assert(b_conn.host === master.host, "b_conn assumed to be master"); -options = { - writeConcern: {w: 1, wtimeout: ReplSetTest.kDefaultTimeoutMS}, - upsert: true -}; -// Inserts another oplog entry to set minValid ahead. -assert.writeOK(b_conn.getDB(name).foo.insert({x: 123})); -var oplog_entry = b_conn.getDB("local").oplog.rs.find().sort({$natural: -1})[0]; -oplog_entry["ts"] = Timestamp(oplog_entry["ts"].t, oplog_entry["ts"].i + 1); -oplog_entry["op"] = "c"; -oplog_entry["o"] = { - "emptycapped": 1 -}; -assert.writeOK(b_conn.getDB("local").oplog.rs.insert(oplog_entry)); - -// Shuts down B and brings back the original master. -replTest.stop(BID); -replTest.restart(AID); -master = replTest.getPrimary(); -assert(a_conn.host === master.host, "a_conn assumed to be master"); - -// Does a write so that B will have to roll back. -options = { - writeConcern: {w: 1, wtimeout: ReplSetTest.kDefaultTimeoutMS}, - upsert: true -}; -assert.writeOK(a_conn.getDB(name).foo.insert({x: 2}, options)); - -// Restarts B, which should attempt to rollback but then fassert. -clearRawMongoProgramOutput(); -replTest.restart(BID); -var msg = RegExp("Can't roll back this command yet: "); -assert.soon(function() { - return rawMongoProgramOutput().match(msg); -}, "Did not see a log entry about skipping the nonrollbackable command during rollback"); - -replTest.stop(BID, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT}); -replTest.stopSet(); diff --git a/jstests/replsets/rollback_refetch_no_uuid/rollback_collMod_PowerOf2Sizes.js b/jstests/replsets/rollback_refetch_no_uuid/rollback_collMod_PowerOf2Sizes.js deleted file mode 100644 index 7b99254961a..00000000000 --- a/jstests/replsets/rollback_refetch_no_uuid/rollback_collMod_PowerOf2Sizes.js +++ /dev/null @@ -1,87 +0,0 @@ -// Test that a rollback of collModding usePowerOf2Sizes and validator can be rolled back. -// -// If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will -// not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a -// scenario, none of the members will have any data, and upon restart will each look for a member to -// inital sync from, so no primary will be elected. This test induces such a scenario, so cannot be -// run on ephemeral storage engines. -// @tags: [requires_persistence] -(function() { - "use strict"; - - function getOptions(conn) { - return conn.getDB(name).foo.exists().options; - } - - // Set up a set and grab things for later. - var name = "rollback_collMod_PowerOf2Sizes"; - var replTest = new ReplSetTest({name: name, nodes: 3}); - var nodes = replTest.nodeList(); - var conns = replTest.startSet(); - replTest.initiate({ - "_id": name, - "members": [ - {"_id": 0, "host": nodes[0]}, - {"_id": 1, "host": nodes[1]}, - {"_id": 2, "host": nodes[2], arbiterOnly: true} - ] - }); - // Get master and do an initial write. - var master = replTest.getPrimary(); - var a_conn = master; - var slaves = replTest.liveNodes.slaves; - var b_conn = slaves[0]; - var AID = replTest.getNodeId(a_conn); - var BID = replTest.getNodeId(b_conn); - - // Create collection with custom options. - var originalCollectionOptions = { - flags: 0, - validator: {x: {$exists: 1}}, - validationLevel: "moderate", - validationAction: "warn" - }; - assert.commandWorked(a_conn.getDB(name).createCollection('foo', originalCollectionOptions)); - - var options = {writeConcern: {w: 2, wtimeout: ReplSetTest.kDefaultTimeoutMS}, upsert: true}; - assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options)); - - assert.eq(getOptions(a_conn), originalCollectionOptions); - assert.eq(getOptions(b_conn), originalCollectionOptions); - - // Stop the slave so it never sees the collMod. - replTest.stop(BID); - - // Run the collMod only on A. - assert.commandWorked(a_conn.getDB(name).runCommand({ - collMod: "foo", - usePowerOf2Sizes: false, - noPadding: true, - validator: {a: 1}, - validationLevel: "moderate", - validationAction: "warn" - })); - assert.eq(getOptions(a_conn), - {flags: 2, validator: {a: 1}, validationLevel: "moderate", validationAction: "warn"}); - - // Shut down A and fail over to B. - replTest.stop(AID); - replTest.restart(BID); - master = replTest.getPrimary(); - assert.eq(b_conn.host, master.host, "b_conn assumed to be master"); - b_conn = master; - - // Do a write on B so that A will have to roll back. - options = {writeConcern: {w: 1, wtimeout: ReplSetTest.kDefaultTimeoutMS}, upsert: true}; - assert.writeOK(b_conn.getDB(name).foo.insert({x: 2}, options)); - - // Restart A, which should rollback the collMod before becoming primary. - replTest.restart(AID); - try { - b_conn.adminCommand({replSetStepDown: 60, secondaryCatchUpPeriodSecs: 60}); - } catch (e) { - // Ignore network disconnect. - } - replTest.waitForState(a_conn, ReplSetTest.State.PRIMARY); - assert.eq(getOptions(a_conn), originalCollectionOptions); -}()); diff --git a/jstests/replsets/rollback_refetch_no_uuid/rollback_collMod_fatal.js b/jstests/replsets/rollback_refetch_no_uuid/rollback_collMod_fatal.js deleted file mode 100644 index 393f7f59004..00000000000 --- a/jstests/replsets/rollback_refetch_no_uuid/rollback_collMod_fatal.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Test that a rollback of collMod altering TTL will cause the node to go into a FATAL state - * - * If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will - * not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a - * scenario, none of the members will have any data, and upon restart will each look for a member to - * initial sync from, so no primary will be elected. This test induces such a scenario, so cannot be - * run on ephemeral storage engines. - * @tags: [requires_persistence] - */ - -// Sets up a replica set and grabs things for later. -var name = "rollback_collMod_fatal"; -var replTest = new ReplSetTest({name: name, nodes: 3}); -var nodes = replTest.nodeList(); -var conns = replTest.startSet(); -replTest.initiate({ - "_id": name, - "members": [ - {"_id": 0, "host": nodes[0], priority: 3}, - {"_id": 1, "host": nodes[1]}, - {"_id": 2, "host": nodes[2], arbiterOnly: true} - ] -}); -var a_conn = conns[0]; -var b_conn = conns[1]; -var AID = replTest.getNodeId(a_conn); -var BID = replTest.getNodeId(b_conn); - -replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY); - -// Gets master and does an initial write. -var master = replTest.getPrimary(); -assert(master === conns[0], "conns[0] assumed to be master"); -assert(a_conn.host === master.host, "a_conn assumed to be master"); -var options = {writeConcern: {w: 2, wtimeout: ReplSetTest.kDefaultTimeoutMS}, upsert: true}; -a_conn.getDB(name).foo.ensureIndex({x: 1}, {expireAfterSeconds: 3600}); -assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options)); - -// Shuts down the master. -replTest.stop(AID); - -// Does a collMod altering TTL which should cause FATAL when rolled back. -master = replTest.getPrimary(); -assert(b_conn.host === master.host, "b_conn assumed to be master"); -assert.commandWorked(b_conn.getDB(name).runCommand( - {collMod: "foo", index: {keyPattern: {x: 1}, expireAfterSeconds: 10}})); - -// Shuts down B and brings back the original master. -replTest.stop(BID); -replTest.restart(AID); -master = replTest.getPrimary(); -assert(a_conn.host === master.host, "a_conn assumed to be master"); - -// Does a write so that B will have to roll back. -options = { - writeConcern: {w: 1, wtimeout: ReplSetTest.kDefaultTimeoutMS}, - upsert: true -}; -assert.writeOK(a_conn.getDB(name).foo.insert({x: 2}, options)); - -// Restarts B, which should attempt rollback but then fassert. -clearRawMongoProgramOutput(); -replTest.restart(BID); -assert.soon(function() { - return rawMongoProgramOutput().match("Cannot roll back a collMod command"); -}, "B failed to fassert"); - -replTest.stop(BID, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT}); -replTest.stopSet(); diff --git a/jstests/replsets/rollback_refetch_no_uuid/rollback_index.js b/jstests/replsets/rollback_refetch_no_uuid/rollback_index.js deleted file mode 100644 index edc5175d10e..00000000000 --- a/jstests/replsets/rollback_refetch_no_uuid/rollback_index.js +++ /dev/null @@ -1,102 +0,0 @@ -// test that a rollback of an index creation op caused the index to be dropped. -// -// If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will -// not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a -// scenario, none of the members will have any data, and upon restart will each look for a member to -// inital sync from, so no primary will be elected. This test induces such a scenario, so cannot be -// run on ephemeral storage engines. -// @tags: [requires_persistence] - -load("jstests/replsets/rslib.js"); - -// function to check the logs for an entry -doesEntryMatch = function(array, regex) { - var found = false; - for (i = 0; i < array.length; i++) { - if (regex.test(array[i])) { - found = true; - } - } - return found; -}; - -// set up a set and grab things for later -var name = "rollback_index"; -var replTest = new ReplSetTest({name: name, nodes: 3}); -var nodes = replTest.nodeList(); -var conns = replTest.startSet(); -replTest.initiate({ - "_id": name, - "members": [ - {"_id": 0, "host": nodes[0], priority: 3}, - {"_id": 1, "host": nodes[1]}, - {"_id": 2, "host": nodes[2], arbiterOnly: true} - ] -}); -var a_conn = conns[0]; -var b_conn = conns[1]; -var AID = replTest.getNodeId(a_conn); -var BID = replTest.getNodeId(b_conn); - -replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY); - -// get master and do an initial write -var master = replTest.getPrimary(); -assert(master === conns[0], "conns[0] assumed to be master"); -assert(a_conn.host === master.host, "a_conn assumed to be master"); -var options = {writeConcern: {w: 2, wtimeout: ReplSetTest.kDefaultTimeoutMS}, upsert: true}; -assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options)); - -// shut down master -replTest.stop(AID); - -// Create a unique index that, if not dropped during rollback, would -// cause errors when applying operations from the primary. -master = replTest.getPrimary(); -assert(b_conn.host === master.host, "b_conn assumed to be master"); -options = { - writeConcern: {w: 1, wtimeout: ReplSetTest.kDefaultTimeoutMS}, - upsert: true -}; -// another insert to set minvalid ahead -assert.writeOK(b_conn.getDB(name).foo.insert({x: 123})); -assert.commandWorked(b_conn.getDB(name).foo.ensureIndex({x: 1}, {unique: true})); -assert.writeError(b_conn.getDB(name).foo.insert({x: 123})); - -// shut down B and bring back the original master -replTest.stop(BID); -replTest.restart(AID); -master = replTest.getPrimary(); -assert(a_conn.host === master.host, "a_conn assumed to be master"); - -// Insert a document with the same value for 'x' that should be -// propagated successfully to B if the unique index was dropped successfully. -options = { - writeConcern: {w: 1, wtimeout: ReplSetTest.kDefaultTimeoutMS} -}; -assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options)); -assert.eq(2, a_conn.getDB(name).foo.find().itcount(), 'invalid number of documents on A'); - -// restart B, which should rollback. -replTest.restart(BID); - -awaitOpTime(b_conn, a_conn); -replTest.awaitReplication(); -replTest.awaitSecondaryNodes(); - -// Perform a write that should succeed if there's no unique index on B. -options = { - writeConcern: {w: 'majority', wtimeout: ReplSetTest.kDefaultTimeoutMS} -}; -assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options)); - -// Check collections and indexes. -assert.eq(3, - b_conn.getDB(name).foo.find().itcount(), - 'Collection on B does not have the same number of documents as A'); -assert.eq( - a_conn.getDB(name).foo.getIndexes().length, - b_conn.getDB(name).foo.getIndexes().length, - 'Unique index not dropped during rollback: ' + tojson(b_conn.getDB(name).foo.getIndexes())); - -replTest.stopSet(); |