diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2018-03-08 10:12:42 -0500 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2018-03-13 15:09:53 -0400 |
commit | 64e649a622b5ac4c1bfad0933132dc7d994b9458 (patch) | |
tree | ff907cca516228300489ed9351819a0bb9c8193b /jstests/replsets | |
parent | 5ce39d9dd292dda65d59dbb18bdc176ea2b528a0 (diff) | |
download | mongo-64e649a622b5ac4c1bfad0933132dc7d994b9458.tar.gz |
SERVER-31802 SERVER-31239 Remove master-slave replication and resync command.
Diffstat (limited to 'jstests/replsets')
-rw-r--r-- | jstests/replsets/initial_sync_document_validation.js | 5 | ||||
-rw-r--r-- | jstests/replsets/initial_sync_fail_insert_once.js | 5 | ||||
-rw-r--r-- | jstests/replsets/read_committed_no_snapshots.js | 43 | ||||
-rw-r--r-- | jstests/replsets/resync.js | 119 | ||||
-rw-r--r-- | jstests/replsets/resync_with_write_load.js | 93 |
5 files changed, 25 insertions, 240 deletions
diff --git a/jstests/replsets/initial_sync_document_validation.js b/jstests/replsets/initial_sync_document_validation.js index 1dd69e0e1d3..06d9388b51d 100644 --- a/jstests/replsets/initial_sync_document_validation.js +++ b/jstests/replsets/initial_sync_document_validation.js @@ -1,6 +1,5 @@ /** - * Tests that initial sync via resync command does not fail if it inserts documents - * which don't validate. + * Tests that initial sync does not fail if it inserts documents which don't validate. */ (function() { @@ -19,7 +18,7 @@ assert.writeOK(coll.insert({_id: 0, x: 1})); assert.commandWorked(coll.runCommand("collMod", {"validator": {a: {$exists: true}}})); - assert.commandWorked(secondary.getDB("admin").runCommand({resync: 1})); + secondary = replSet.restart(secondary, {startClean: true}); replSet.awaitReplication(); replSet.awaitSecondaryNodes(); diff --git a/jstests/replsets/initial_sync_fail_insert_once.js b/jstests/replsets/initial_sync_fail_insert_once.js index a565c64216d..d85f97f5a63 100644 --- a/jstests/replsets/initial_sync_fail_insert_once.js +++ b/jstests/replsets/initial_sync_fail_insert_once.js @@ -24,9 +24,8 @@ data: {collectionNS: coll.getFullName()} })); - jsTest.log("Issuing RESYNC command to " + tojson(secondary)); - assert.commandWorked(secondary.getDB("admin").runCommand({resync: 1})); - + jsTest.log("Re-syncing " + tojson(secondary)); + secondary = replSet.restart(secondary, {startClean: true}); replSet.awaitReplication(); replSet.awaitSecondaryNodes(); diff --git a/jstests/replsets/read_committed_no_snapshots.js b/jstests/replsets/read_committed_no_snapshots.js index 9adfdc37502..83ba451e836 100644 --- a/jstests/replsets/read_committed_no_snapshots.js +++ b/jstests/replsets/read_committed_no_snapshots.js @@ -27,7 +27,7 @@ load("jstests/replsets/rslib.js"); // For reconfig and startSetIfSupportsReadMa "members": [ {"_id": 0, "host": nodes[0]}, {"_id": 1, "host": nodes[1], priority: 0}, - {"_id": 2, "host": nodes[2], arbiterOnly: true} + {"_id": 2, "host": nodes[2], priority: 0} ], "protocolVersion": 1 }; @@ -36,12 +36,15 @@ load("jstests/replsets/rslib.js"); // For reconfig and startSetIfSupportsReadMa // Get connections and collection. var primary = replTest.getPrimary(); - var secondary = replTest.liveNodes.slaves[0]; - var secondaryId = replTest.getNodeId(secondary); - var db = primary.getDB(name); + var healthySecondary = replTest.liveNodes.slaves[0]; + healthySecondary.setSlaveOk(); + var noSnapshotSecondary = replTest.liveNodes.slaves[1]; + noSnapshotSecondary.setSlaveOk(); + assert.commandWorked(noSnapshotSecondary.adminCommand( + {configureFailPoint: 'disableSnapshotting', mode: 'alwaysOn'})); // Do a write, wait for it to replicate, and ensure it is visible. - var res = db.runCommandWithMetadata( // + var res = primary.getDB(name).runCommandWithMetadata( // { insert: "foo", documents: [{_id: 1, state: 0}], @@ -50,36 +53,32 @@ load("jstests/replsets/rslib.js"); // For reconfig and startSetIfSupportsReadMa {"$replData": 1}); assert.commandWorked(res.commandReply); - // We need to propagate the lastOpVisible from the primary as afterOpTime in the secondary to - // ensure - // we wait for the write to be in the majority committed view. + // We need to propagate the lastOpVisible from the primary as afterOpTime in the secondaries to + // ensure we wait for the write to be in the majority committed view. var lastOp = res.metadata["$replData"].lastOpVisible; - secondary.setSlaveOk(); // Timeout is based on heartbeat timeout. - assert.commandWorked(secondary.getDB(name).foo.runCommand( + assert.commandWorked(healthySecondary.getDB(name).foo.runCommand( 'find', {"readConcern": {"level": "majority", "afterOpTime": lastOp}, "maxTimeMS": 10 * 1000})); - // Disable snapshotting via failpoint - secondary.adminCommand({configureFailPoint: 'disableSnapshotting', mode: 'alwaysOn'}); - - // Resync to drop any existing snapshots - secondary.adminCommand({resync: 1}); - // Ensure maxTimeMS times out while waiting for this snapshot - assert.commandFailed(secondary.getDB(name).foo.runCommand( - 'find', {"readConcern": {"level": "majority"}, "maxTimeMS": 1000})); + assert.commandFailedWithCode( + noSnapshotSecondary.getDB(name).foo.runCommand( + 'find', {"readConcern": {"level": "majority"}, "maxTimeMS": 1000}), + ErrorCodes.ExceededTimeLimit); - // Reconfig to make the secondary the primary + // Reconfig to make the no-snapshot secondary the primary var config = primary.getDB("local").system.replset.findOne(); config.members[0].priority = 0; - config.members[1].priority = 3; + config.members[2].priority = 1; config.version++; primary = reconfig(replTest, config, true); // Ensure maxTimeMS times out while waiting for this snapshot - assert.commandFailed(primary.getSiblingDB(name).foo.runCommand( - 'find', {"readConcern": {"level": "majority"}, "maxTimeMS": 1000})); + assert.commandFailedWithCode( + primary.getSiblingDB(name).foo.runCommand( + 'find', {"readConcern": {"level": "majority"}, "maxTimeMS": 1000}), + ErrorCodes.ExceededTimeLimit); replTest.stopSet(); })(); diff --git a/jstests/replsets/resync.js b/jstests/replsets/resync.js deleted file mode 100644 index 8a6a35ee699..00000000000 --- a/jstests/replsets/resync.js +++ /dev/null @@ -1,119 +0,0 @@ -// test that the resync command works with replica sets and that one does not need to manually -// force a replica set resync by deleting all datafiles -// Also tests that you can do this from a node that is "too stale" -// -// This test requires persistence in order for a restarted node with a stale oplog to stay in the -// RECOVERING state. A restarted node with an ephemeral storage engine will not have an oplog upon -// restart, so will immediately resync. -// @tags: [requires_persistence] -(function() { - "use strict"; - - var replTest = new ReplSetTest({ - name: 'resync', - nodes: 3, - oplogSize: 1, - // At the end of this test we call resync on a node that may have blacklisted the only other - // data bearing node. We need to ensure that the resync attempt will keep looking for a - // sync source for at least 60 seconds, until the blacklist period ends. Since we sleep 1 - // second in between each attempt to find a sync source, setting the number of attempts to - // find a sync source to larger than 60 should ensure that the resync attempt is able to - // succeed. - nodeOptions: {setParameter: "numInitialSyncConnectAttempts=90"} - }); - var nodes = replTest.nodeList(); - - var conns = replTest.startSet(); - var r = replTest.initiate({ - "_id": "resync", - "members": [ - {"_id": 0, "host": nodes[0], priority: 1}, - {"_id": 1, "host": nodes[1], priority: 0}, - {"_id": 2, "host": nodes[2], arbiterOnly: true} - ] - }); - - var a_conn = conns[0]; - // Make sure we have a master, and it is conns[0] - replTest.waitForState(a_conn, ReplSetTest.State.PRIMARY); - var b_conn = conns[1]; - a_conn.setSlaveOk(); - b_conn.setSlaveOk(); - var A = a_conn.getDB("test"); - var B = b_conn.getDB("test"); - var AID = replTest.getNodeId(a_conn); - var BID = replTest.getNodeId(b_conn); - - // create an oplog entry with an insert - assert.writeOK( - A.foo.insert({x: 1}, {writeConcern: {w: 2, wtimeout: ReplSetTest.kDefaultTimeoutMS}})); - assert.eq(B.foo.findOne().x, 1); - - // run resync and wait for it to happen - assert.commandWorked(b_conn.getDB("admin").runCommand({resync: 1})); - replTest.awaitReplication(); - replTest.awaitSecondaryNodes(); - - assert.eq(B.foo.findOne().x, 1); - replTest.stop(BID); - - function hasCycled() { - var oplog = a_conn.getDB("local").oplog.rs; - try { - // Collection scan to determine if the oplog entry from the first insert has been - // deleted yet. - return oplog.find({"o.x": 1}).sort({$natural: 1}).limit(10).itcount() == 0; - } catch (except) { - // An error is expected in the case that capped deletions blow away the position of the - // collection scan during a yield. In this case, we just try again. - var errorRegex = /CappedPositionLost/; - assert(errorRegex.test(except.message)); - return hasCycled(); - } - } - - jsTestLog("Rolling over oplog"); - - // Make sure the oplog has rolled over on the primary and secondary that is up, - // so when we bring up the other replica it is "too stale" - for (var cycleNumber = 0; cycleNumber < 10; cycleNumber++) { - // insert enough to cycle oplog - var bulk = A.foo.initializeUnorderedBulkOp(); - for (var i = 2; i < 10000; i++) { - bulk.insert({x: i}); - } - - // wait for secondary to also have its oplog cycle - assert.writeOK(bulk.execute({w: 1, wtimeout: ReplSetTest.kDefaultTimeoutMS})); - - if (hasCycled()) - break; - } - - assert(hasCycled()); - - jsTestLog("Restarting node B"); - // bring node B and it will enter recovery mode because its newest oplog entry is too old - replTest.restart(BID); - - jsTestLog("Waiting for node B to to into RECOVERING"); - // check that it is in recovery mode - assert.soon(function() { - try { - var result = b_conn.getDB("admin").runCommand({replSetGetStatus: 1}); - return (result.members[1].stateStr === "RECOVERING"); - } catch (e) { - print(e); - } - }, "node didn't enter RECOVERING state"); - - jsTestLog("Resync node B"); - // run resync and wait for it to happen - assert.commandWorked(b_conn.getDB("admin").runCommand({resync: 1})); - replTest.awaitReplication(); - replTest.awaitSecondaryNodes(); - assert.eq(B.foo.findOne().x, 1); - - replTest.stopSet(15); - jsTest.log("success"); -})(); diff --git a/jstests/replsets/resync_with_write_load.js b/jstests/replsets/resync_with_write_load.js deleted file mode 100644 index 10df8501b91..00000000000 --- a/jstests/replsets/resync_with_write_load.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * This test creates a replica set and writes during the resync call in order to verify - * that all phases of the resync/initial-sync process work correctly. - * - */ - -// Test disabled because resync still has a race where it doesn't reset its last fetched optime -// before trying to run initial sync, which results in an upstream query with a $gte that might -// return an empty batch. -if (false) { - var testName = "resync_with_write_load"; - var replTest = new ReplSetTest({name: testName, nodes: 3, oplogSize: 100}); - var nodes = replTest.nodeList(); - - var conns = replTest.startSet(); - var config = { - "_id": testName, - "members": [ - {"_id": 0, "host": nodes[0]}, - {"_id": 1, "host": nodes[1], priority: 0}, - {"_id": 2, "host": nodes[2], priority: 0} - ], - settings: {chainingAllowed: false} - }; - var r = replTest.initiate(config); - replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY); - // Make sure we have a master - var master = replTest.getPrimary(); - var a_conn = conns[0]; - var b_conn = conns[1]; - a_conn.setSlaveOk(); - b_conn.setSlaveOk(); - var A = a_conn.getDB("test"); - var B = b_conn.getDB("test"); - var AID = replTest.getNodeId(a_conn); - var BID = replTest.getNodeId(b_conn); - - assert(master == conns[0], "conns[0] assumed to be master"); - assert(a_conn.host == master.host); - - // create an oplog entry with an insert - assert.writeOK( - A.foo.insert({x: 1}, {writeConcern: {w: 3, wtimeout: ReplSetTest.kDefaultTimeoutMS}})); - - print("******************** starting load for 30 secs *********************"); - var work = function() { - print("starting loadgen"); - var start = new Date().getTime(); - - assert.writeOK(db.timeToStartTrigger.insert({_id: 1})); - - while (true) { - for (x = 0; x < 100; x++) { - db["a" + x].insert({a: x}); - } - - var runTime = (new Date().getTime() - start); - if (runTime > 30000) - break; - else if (runTime < 5000) // back-off more during first 2 seconds - sleep(50); - else - sleep(1); - } - print("finshing loadgen"); - }; - // insert enough that resync node has to go through oplog replay in each step - var loadGen = startParallelShell(work, replTest.ports[0]); - - // wait for document to appear to continue - assert.soon(function() { - try { - return 1 == master.getDB("test")["timeToStartTrigger"].find().itcount(); - } catch (e) { - print(e); - return false; - } - }, "waited too long for start trigger", 90 * 1000 /* 90 secs */); - - print("*************** issuing resync command ***************"); - assert.commandWorked(B.adminCommand("resync")); - - print("waiting for load generation to finish"); - loadGen(); - - // Make sure oplogs & dbHashes match - replTest.checkOplogs(testName); - replTest.checkReplicatedDataHashes(testName); - - replTest.stopSet(); - - print("*****test done******"); -} |