diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-03-18 08:53:15 -0400 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-03-22 17:46:18 -0400 |
commit | d370aed86df0489e8ff7ee308f4faefa54b57c05 (patch) | |
tree | 836d6bca01a8920d92da7cdc3a17c3f2a92408d9 /jstests | |
parent | 3038797f87b9e355ff5151777b8474e57adb419c (diff) | |
download | mongo-d370aed86df0489e8ff7ee308f4faefa54b57c05.tar.gz |
SERVER-37255 Fix invariant when reconfig races with election
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/replsets/reconfig_during_election.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/jstests/replsets/reconfig_during_election.js b/jstests/replsets/reconfig_during_election.js new file mode 100644 index 00000000000..4f58b3cd477 --- /dev/null +++ b/jstests/replsets/reconfig_during_election.js @@ -0,0 +1,49 @@ +/** + * SERVER-37255: replSetReconfig runs on a node that is concurrently processing an election win. + */ + +(function() { + "use strict"; + load("jstests/replsets/libs/election_handoff.js"); + load("jstests/libs/check_log.js"); + + const rst = ReplSetTest({nodes: 2}); + const nodes = rst.startSet(); + const config = rst.getReplSetConfig(); + // Prevent elections and set heartbeat timeout >> electionHangsBeforeUpdateMemberState. + config.settings = {electionTimeoutMillis: 12 * 60 * 60 * 1000, heartbeatTimeoutSecs: 60 * 1000}; + rst.initiate(config); + + const incumbent = rst.getPrimary(); + const candidate = rst.getSecondary(); + + jsTestLog("Step down"); + + assert.commandWorked(candidate.adminCommand({ + configureFailPoint: "electionHangsBeforeUpdateMemberState", + mode: "alwaysOn", + data: {waitForMillis: 10 * 1000} + })); + + // The incumbent sends replSetStepUp to the candidate for election handoff. + assert.adminCommandWorkedAllowingNetworkError(incumbent, { + replSetStepDown: ElectionHandoffTest.stepDownPeriodSecs, + secondaryCatchUpPeriodSecs: ElectionHandoffTest.stepDownPeriodSecs / 2 + }); + + jsTestLog("Wait for candidate to win the election"); + + checkLog.contains( + candidate, "election succeeded - electionHangsBeforeUpdateMemberState fail point enabled"); + + jsTestLog("Try to interrupt it with a reconfig"); + + config.members[nodes.indexOf(candidate)].priority = 2; + config.version++; + assert.commandWorked(candidate.adminCommand({replSetReconfig: config, force: true})); + + assert.commandWorked(candidate.adminCommand( + {configureFailPoint: "electionHangsBeforeUpdateMemberState", mode: "off"})); + + rst.stopSet(); +})();
\ No newline at end of file |