diff options
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/replsets/maxSyncSourceLagSecs.js | 19 | ||||
-rw-r--r-- | jstests/replsets/rslib.js | 12 |
2 files changed, 27 insertions, 4 deletions
diff --git a/jstests/replsets/maxSyncSourceLagSecs.js b/jstests/replsets/maxSyncSourceLagSecs.js index a9aaa104c59..a00ad8a7bef 100644 --- a/jstests/replsets/maxSyncSourceLagSecs.js +++ b/jstests/replsets/maxSyncSourceLagSecs.js @@ -25,6 +25,12 @@ }); replTest.awaitNodesAgreeOnPrimary(); + // Disable maxSyncSourceLagSecs behavior until we've established the spanning tree we want. + replTest.nodes.forEach(function(node) { + assert.commandWorked(node.getDB('admin').runCommand( + {configureFailPoint: 'disableMaxSyncSourceLagSecs', mode: 'alwaysOn'})); + }); + var master = replTest.getPrimary(); var slaves = replTest.liveNodes.slaves; syncFrom(slaves[0], master, replTest); @@ -32,13 +38,20 @@ master.getDB("foo").bar.save({a: 1}); replTest.awaitReplication(); + jsTestLog("Setting sync target of slave 2 to slave 1"); + syncFrom(slaves[1], slaves[0], replTest); + printjson(replTest.status()); + // need to put at least maxSyncSourceLagSecs b/w first op and subsequent ops // so that the shouldChangeSyncSource logic goes into effect sleep(4000); - jsTestLog("Setting sync target of slave 2 to slave 1"); - syncFrom(slaves[1], slaves[0], replTest); - printjson(replTest.status()); + // Re-enable maxSyncSourceLagSecs behavior now that we have the spanning tree we want and are + // ready to test that behavior. + replTest.nodes.forEach(function(node) { + assert.commandWorked(node.getDB('admin').runCommand( + {configureFailPoint: 'disableMaxSyncSourceLagSecs', mode: 'off'})); + }); jsTestLog("Lock slave 1 and add some docs. Force sync target for slave 2 to change to primary"); assert.commandWorked(slaves[0].getDB("admin").runCommand({fsync: 1, lock: 1})); diff --git a/jstests/replsets/rslib.js b/jstests/replsets/rslib.js index 3ca7e66d85b..b97f79c00d1 100644 --- a/jstests/replsets/rslib.js +++ b/jstests/replsets/rslib.js @@ -22,14 +22,24 @@ var startSetIfSupportsReadMajority; */ syncFrom = function(syncingNode, desiredSyncSource, rst) { jsTestLog("Forcing " + syncingNode.name + " to sync from " + desiredSyncSource.name); - stopServerReplication(syncingNode); + + // Ensure that 'desiredSyncSource' doesn't already have the dummy write sitting around from + // a previous syncFrom attempt. var dummyName = "dummyForSyncFrom"; + rst.getPrimary().getDB(dummyName).getCollection(dummyName).drop(); + assert.soonNoExcept(function() { + return desiredSyncSource.getDB(dummyName).getCollection(dummyName).findOne() == null; + }); + + stopServerReplication(syncingNode); + assert.writeOK(rst.getPrimary().getDB(dummyName).getCollection(dummyName).insert({a: 1})); // Wait for 'desiredSyncSource' to get the dummy write we just did so we know it's // definitely ahead of 'syncingNode' before we call replSetSyncFrom. assert.soonNoExcept(function() { return desiredSyncSource.getDB(dummyName).getCollection(dummyName).findOne({a: 1}); }); + assert.commandWorked(syncingNode.adminCommand({replSetSyncFrom: desiredSyncSource.name})); restartServerReplication(syncingNode); rst.awaitSyncSource(syncingNode, desiredSyncSource); |