diff options
-rw-r--r-- | jstests/sharding/migration_coordinator_shutdown_in_critical_section.js | 2 | ||||
-rw-r--r-- | jstests/sharding/repl_monitor_refresh.js | 2 | ||||
-rw-r--r-- | jstests/sharding/startup_with_all_configs_down.js | 2 | ||||
-rw-r--r-- | src/mongo/shell/replsettest.js | 17 | ||||
-rw-r--r-- | src/mongo/shell/shardingtest.js | 146 |
5 files changed, 12 insertions, 157 deletions
diff --git a/jstests/sharding/migration_coordinator_shutdown_in_critical_section.js b/jstests/sharding/migration_coordinator_shutdown_in_critical_section.js index cf0ad33b1c1..f2fb240bb35 100644 --- a/jstests/sharding/migration_coordinator_shutdown_in_critical_section.js +++ b/jstests/sharding/migration_coordinator_shutdown_in_critical_section.js @@ -70,7 +70,7 @@ function testShutDownAfterFailPoint(failPointName) { assert.eq(0, MongoRunner.stopMongod(st.rs0.getPrimary(), null, {}, true /* waitpid */)); awaitResult(); - st.stop({parallelSupported: false}); + st.stop(); } testShutDownAfterFailPoint("hangInEnsureChunkVersionIsGreaterThanInterruptible"); diff --git a/jstests/sharding/repl_monitor_refresh.js b/jstests/sharding/repl_monitor_refresh.js index f65a495d3b7..b41fc42d761 100644 --- a/jstests/sharding/repl_monitor_refresh.js +++ b/jstests/sharding/repl_monitor_refresh.js @@ -86,5 +86,5 @@ assert.soon( shardDoc.host.split(',').length + " in " + shardDoc.host); }); -st.stop({parallelSupported: false}); +st.stop(); }()); diff --git a/jstests/sharding/startup_with_all_configs_down.js b/jstests/sharding/startup_with_all_configs_down.js index 06d2ceefb00..67d94812399 100644 --- a/jstests/sharding/startup_with_all_configs_down.js +++ b/jstests/sharding/startup_with_all_configs_down.js @@ -85,6 +85,6 @@ assert.soon(function() { assert.eq(100, newMongosConn.getDB('test').foo.find().itcount()); -st.stop({parallelSupported: false}); +st.stop(); MongoRunner.stopMongos(newMongosInfo); }()); diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index 3f155db9ba0..5dd402a89d7 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -3338,22 +3338,17 @@ var ReplSetTest = function(opts) { * Constructor, which instantiates the ReplSetTest object from existing nodes. */ function _constructFromExistingNodes( - {name, serverless, nodeHosts, nodeOptions, keyFile, host, waitForKeys, nodes = undefined}) { + {name, serverless, nodeHosts, nodeOptions, keyFile, host, waitForKeys}) { print('Recreating replica set from existing nodes ' + tojson(nodeHosts)); self.name = name; self.serverless = serverless; self.ports = nodeHosts.map(node => node.split(':')[1]); - if (nodes) { - self.nodes = nodes; - } else { - self.nodes = nodeHosts.map((node) => { - const conn = Mongo(node); - conn.name = conn.host; - conn.port = node.split(':')[1]; - return conn; - }); - } + self.nodes = nodeHosts.map((node) => { + const conn = Mongo(node); + conn.name = conn.host; + return conn; + }); self.host = host; self.waitForKeys = waitForKeys; self.keyFile = keyFile; diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js index 1b5af0bbc66..7117f7575ac 100644 --- a/src/mongo/shell/shardingtest.js +++ b/src/mongo/shell/shardingtest.js @@ -364,150 +364,10 @@ var ShardingTest = function(params) { this.configRS.stopSet(undefined, forRestart, opts); }; - /** - * Returns boolean for whether the sharding test is compatible to shutdown in parallel. - */ - function isShutdownParallelSupported(opts = {}) { - if (!tryLoadParallelTester()) { - return false; - } - - if (otherParams.useBridge) { - // Keep the current behavior of shutting down each replica set shard and the - // CSRS individually when otherParams.useBridge === true. There appear to only - // be 8 instances of {useBridge: true} with ShardingTest and the implementation - // complexity is too high - return false; - } - - if (otherParams.configOptions && otherParams.configOptions.clusterAuthMode === "x509") { - // The mongo shell performing X.509 authentication as a cluster member requires - // starting a parallel shell and using the server's (not the client's) - // certificate. The ReplSetTest instance constructed in a Thread wouldn't have - // copied the path to the server's certificate. We therefore fall back to - // initiating the CSRS and replica set shards sequentially when X.509 - // authentication is being used. - return false; - } - - if (otherParams.configOptions && otherParams.configOptions.tlsMode === "preferTLS") { - return false; - } - - if (otherParams.configOptions && otherParams.configOptions.sslMode === "requireSSL") { - return false; - } - - if (opts.parallelSupported !== undefined && opts.parallelSupported === false) { - // The test has chosen to opt out of parallel shutdown - return false; - } - - return true; - } - - /** - * Returns the replica sets args for sets that are to be terminated in parallel threads. - */ - function replicaSetsToTerminate(shardRS) { - const replicaSetsToTerminate = []; - [...(shardRS.map(obj => obj.test))].forEach(rst => { - // Generating a list of live nodes in the replica set - liveNodes = []; - rst.nodes.forEach(function(node) { - try { - node.getDB('admin')._helloOrLegacyHello(); - } catch (err) { - // Ignore since the node is not live - return; - } - - if (!node.pid) { - // Getting the pid for the node - rst.keyFile = rst.keyFile ? rst.keyFile : this.keyFile; - if (rst.keyFile) { - serverStatus = authutil.asCluster(node, rst.keyFile, () => { - return node.getDB("admin").serverStatus(); - }); - } else { - serverStatus = node.getDB("admin").serverStatus(); - } - - if (serverStatus["pid"]) { - node.pid = serverStatus["pid"].valueOf(); - } else { - // Shutdown requires PID values for every node. The case we are - // unable to obtain a PID value is rare, however, should it - // occur, the code will throw this error. - throw 'Could not obtain node PID value. Shutdown failed.'; - } - } - - liveNodes.push(node); - }); - - if (liveNodes.length > 0) { - replicaSetsToTerminate.push({ - // Arguments for each replica set within parallel threads. - rstArgs: { - name: rst.name, - nodeHosts: liveNodes.map(node => `${node.host}`), - nodeOptions: rst.nodeOptions, - // Mixed-mode SSL tests may specify a keyFile per replica set rather - // than one for the whole cluster. - keyFile: rst.keyFile ? rst.keyFile : this.keyFile, - host: otherParams.useHostname ? hostName : "localhost", - waitForKeys: false, - nodes: liveNodes - }, - }); - } + this.stopAllShards = function(opts, forRestart = undefined) { + this._rs.forEach((rs) => { + rs.test.stopSet(15, forRestart, opts); }); - return replicaSetsToTerminate; - } - - this.stopAllShards = function(opts = {}, forRestart = undefined) { - if (isShutdownParallelSupported(opts)) { - const threads = []; - try { - for (let {rstArgs} of replicaSetsToTerminate(this._rs)) { - const thread = new Thread((rstArgs, signal, forRestart, opts) => { - try { - const rst = new ReplSetTest({rstArgs}); - rst.stopSet(signal, forRestart, opts); - return {ok: 1}; - } catch (e) { - return { - ok: 0, - hosts: rstArgs.nodeHosts, - name: rstArgs.name, - error: e.toString(), - stack: e.stack, - }; - } - }, rstArgs, 15, forRestart, opts); - - thread.start(); - threads.push(thread); - } - } finally { - // Wait for each thread to finish. Throw an error if any thread fails. - const returnData = threads.map(thread => { - thread.join(); - return thread.returnData(); - }); - - returnData.forEach(res => { - assert.commandWorked(res, - 'terminating shard or config server replica sets failed'); - }); - } - } else { - // The replica sets shutting down serially - this._rs.forEach((rs) => { - rs.test.stopSet(15, forRestart, opts); - }); - } }; this.stopAllMongos = function(opts) { |