From 60897d8e3b1bd24504993899d82e9785ca5107ff Mon Sep 17 00:00:00 2001 From: Spencer T Brody Date: Wed, 5 Sep 2018 17:15:18 -0400 Subject: SERVER-37010 Prevent unexpected elections in initial_sync4.js and initial_sync_rename_collection*.js (cherry picked from commit 70a2ad8b39624a5ecb82bfa53e41eeb1ba2e3cdb) --- jstests/replsets/initial_sync4.js | 2 +- jstests/replsets/initial_sync_rename_collection.js | 7 ++++++- 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. -- cgit v1.2.1