diff options
author | Spencer T Brody <spencer@mongodb.com> | 2018-09-05 17:15:18 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2018-09-06 17:32:26 -0400 |
commit | 60897d8e3b1bd24504993899d82e9785ca5107ff (patch) | |
tree | c0564e508f69962f83327062a6d50790ddd3a0c4 | |
parent | 8475a86d46d4ee2ce96b0271407706a6c9afc62f (diff) | |
download | mongo-60897d8e3b1bd24504993899d82e9785ca5107ff.tar.gz |
SERVER-37010 Prevent unexpected elections in initial_sync4.js and initial_sync_rename_collection*.jsr3.6.8-rc0
(cherry picked from commit 70a2ad8b39624a5ecb82bfa53e41eeb1ba2e3cdb)
-rw-r--r-- | jstests/replsets/initial_sync4.js | 2 | ||||
-rw-r--r-- | jstests/replsets/initial_sync_rename_collection.js | 7 | ||||
-rw-r--r-- | jstests/replsets/initial_sync_rename_collection_unsafe.js | 7 |
3 files changed, 13 insertions, 3 deletions
diff --git a/jstests/replsets/initial_sync4.js b/jstests/replsets/initial_sync4.js index 89b5f42f39a..504e7e737ab 100644 --- a/jstests/replsets/initial_sync4.js +++ b/jstests/replsets/initial_sync4.js @@ -34,7 +34,7 @@ var config = replTest.getReplSetConfig(); config.version = replTest.getReplSetConfigFromNode().version + 1; - config.members.push({_id: 2, host: hostname + ":" + s.port, priority: 0}); + config.members.push({_id: 2, host: hostname + ":" + s.port, priority: 0, votes: 0}); try { m.getDB("admin").runCommand({replSetReconfig: config}); } catch (e) { diff --git a/jstests/replsets/initial_sync_rename_collection.js b/jstests/replsets/initial_sync_rename_collection.js index fdb77ea6da4..fa68297bf6c 100644 --- a/jstests/replsets/initial_sync_rename_collection.js +++ b/jstests/replsets/initial_sync_rename_collection.js @@ -27,7 +27,12 @@ jsTestLog('Bring up a new node'); const secondary = rst.add({setParameter: 'numInitialSyncAttempts=1'}); - rst.reInitiate(); + + jsTestLog('Begin initial sync on secondary'); + let conf = rst.getPrimary().getDB('admin').runCommand({replSetGetConfig: 1}).config; + conf.members.push({_id: 1, host: secondary.host, priority: 0, votes: 0}); + conf.version++; + assert.commandWorked(rst.getPrimary().getDB('admin').runCommand({replSetReconfig: conf})); assert.eq(primary, rst.getPrimary(), 'Primary changed after reconfig'); jsTestLog('Wait for new node to start cloning'); diff --git a/jstests/replsets/initial_sync_rename_collection_unsafe.js b/jstests/replsets/initial_sync_rename_collection_unsafe.js index 76cb8af38e0..dc8f6783e0c 100644 --- a/jstests/replsets/initial_sync_rename_collection_unsafe.js +++ b/jstests/replsets/initial_sync_rename_collection_unsafe.js @@ -25,7 +25,12 @@ const secondary = rst.add({setParameter: {allowUnsafeRenamesDuringInitialSync: true}}); assert.commandWorked(secondary.adminCommand( {configureFailPoint: 'initialSyncHangBeforeCopyingDatabases', mode: 'alwaysOn'})); - rst.reInitiate(); + + jsTestLog('Begin initial sync on secondary'); + let conf = rst.getPrimary().getDB('admin').runCommand({replSetGetConfig: 1}).config; + conf.members.push({_id: 1, host: secondary.host, priority: 0, votes: 0}); + conf.version++; + assert.commandWorked(rst.getPrimary().getDB('admin').runCommand({replSetReconfig: conf})); assert.eq(primary, rst.getPrimary(), 'Primary changed after reconfig'); // Wait for fail point message to be logged. |