diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-11-02 17:05:22 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-02 22:30:45 +0000 |
commit | 72aacd4ffaf6500777a8a51f87b0797f8ea8ad0b (patch) | |
tree | 5de4d7a82905d9d0fe9961b52b768d5bb86de5c3 /jstests | |
parent | 12646ec5380bcc0dc10c66069a6583c653683922 (diff) | |
download | mongo-72aacd4ffaf6500777a8a51f87b0797f8ea8ad0b.tar.gz |
SERVER-33747 Fix crash when arbiter restarts and enters REMOVED
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/replsets/arbiter_new_hostname.js | 46 | ||||
-rw-r--r-- | jstests/replsets/rslib.js | 2 |
2 files changed, 47 insertions, 1 deletions
diff --git a/jstests/replsets/arbiter_new_hostname.js b/jstests/replsets/arbiter_new_hostname.js new file mode 100644 index 00000000000..dd7bc11fd36 --- /dev/null +++ b/jstests/replsets/arbiter_new_hostname.js @@ -0,0 +1,46 @@ +/* + * An arbiter that is stopped and restarted on a different port and rejoins the + * replica set should enter removed state and should not start data replication. + * + * @tags: [ + * requires_fcv_49, + * ] + */ +(function() { +"use strict"; +const replTest = new ReplSetTest({name: 'test', nodes: 3}); +replTest.startSet(); +const nodes = replTest.nodeList(); +let config = { + "_id": "test", + "members": [ + {"_id": 0, "host": nodes[0]}, + {"_id": 1, "host": nodes[1]}, + {"_id": 2, "host": nodes[2], arbiterOnly: true} + ] +}; +replTest.initiate(config); + +let primary = replTest.getPrimary(); +replTest.awaitReplication(); +replTest.awaitSecondaryNodes(); + +const arbiterId = 2; +const newPort = replTest.getPort(arbiterId) + 1; +jsTestLog("Restarting the arbiter node on a new port: " + newPort); +replTest.stop(arbiterId); +replTest.start(arbiterId, {port: newPort}, true); + +jsTestLog("Reconfiguring the set to change the arbiter's port."); +config = replTest.getReplSetConfigFromNode(); +jsTestLog(`Original config: ${tojson(config)}`); + +const hostname = config.members[arbiterId].host.split(":")[0]; +config.version++; +config.members[arbiterId].host = hostname + ":" + newPort; +jsTestLog(`New config: ${tojson(config)}`); +assert.commandWorked(primary.getDB("admin").runCommand({replSetReconfig: config})); +replTest.awaitReplication(); +replTest.awaitNodesAgreeOnConfigVersion(); +replTest.stopSet(); +}()); diff --git a/jstests/replsets/rslib.js b/jstests/replsets/rslib.js index 67bc0df09f5..b193022c1ff 100644 --- a/jstests/replsets/rslib.js +++ b/jstests/replsets/rslib.js @@ -218,7 +218,7 @@ function reconfigWithRetry(primary, config, force) { const newVersion = assert.commandWorked(admin.runCommand({replSetGetConfig: 1})).config.version + 1; reconfigCommand.replSetReconfig.version = newVersion; - const res = admin.runCommand(reconfigCommand); + let res = admin.runCommand(reconfigCommand); // Retry reconfig if quorum check failed because not enough voting nodes responded. One // reason for this is if the connections used for heartbeats get closed on the destination |