load("jstests/libs/fail_point_util.js"); // For configureFailPoint.
|
//
|
// Test sending a vote request to a removed node.
|
//
|
|
// Start out with {n1, n2, n3}
|
let rst = new ReplSetTest({nodes: 3});
|
rst.startSet();
|
rst.initiate();
|
|
let primary = rst.getPrimary();
|
|
// Save the host of the node that will become removed.
|
let removedHost = rst.nodes[2].host;
|
|
// Remove n3 from the config.
|
let config = rst.getReplSetConfigFromNode();
|
let origConfig = Object.assign({}, config);
|
config.members = config.members.slice(0, 2);
|
config.version++;
|
assert.commandWorked(primary.adminCommand({replSetReconfig: config}));
|
|
// Give plenty of time for config to propagate.
|
sleep(5000);
|
|
// Block the removed secondary from installing new configs via heartbeat at this point. This is to
|
// simulate a case where heartbeats are propagating very slowly for some reason between nodes.
|
let removedConn = new Mongo(removedHost);
|
let fp = configureFailPoint(removedConn, "blockHeartbeatReconfigFinish");
|
|
// Reconfig back to the original config: {n1, n2, n3}. n3 will not hear about this yet, though,
|
// and still think it is REMOVED.
|
origConfig.version = config.version + 1;
|
assert.commandWorked(primary.adminCommand({replSetReconfig: origConfig}));
|
|
// Step down the primary and back up again. It should send a vote request to the REMOVED node.
|
assert.commandWorked(primary.adminCommand({replSetStepDown: 1, force: true}));
|
sleep(2000);
|
assert.commandWorked(primary.adminCommand({replSetStepUp: 1}));
|
rst.getPrimary();
|
|
rst.stopSet();
|