diff options
author | Drew Paroski <drew.paroski@mongodb.com> | 2020-05-11 12:25:37 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-11 16:37:51 +0000 |
commit | af62a3eeaf0b1101cb2f6e8e7595b70f2fe2f10f (patch) | |
tree | 2f2e10ab0491f8b63b0155a7274b96247791a3b0 | |
parent | 0eebd4bdf5e3b771c3623341f5bc6184261c2db2 (diff) | |
download | mongo-af62a3eeaf0b1101cb2f6e8e7595b70f2fe2f10f.tar.gz |
Revert "SERVER-46686 Update explain() shell command to propagate "maxTimeMS" arg to top-level"
This reverts commit d7d3a0d782ced557c26b9eb81ea97cc242762c8f.
-rw-r--r-- | jstests/noPassthrough/explain_max_time_ms.js | 82 | ||||
-rw-r--r-- | src/mongo/shell/explain_query.js | 5 | ||||
-rw-r--r-- | src/mongo/shell/explainable.js | 21 |
3 files changed, 4 insertions, 104 deletions
diff --git a/jstests/noPassthrough/explain_max_time_ms.js b/jstests/noPassthrough/explain_max_time_ms.js deleted file mode 100644 index 72077f48b27..00000000000 --- a/jstests/noPassthrough/explain_max_time_ms.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Tests the explain command with the maxTimeMS option. - */ -(function() { -"use strict"; - -const standalone = MongoRunner.runMongod(); -assert.neq(null, conn, "mongod was unable to start up"); - -const dbName = "test"; -const db = standalone.getDB(dbName); -const collName = "explain_max_time_ms"; -const coll = db.getCollection(collName); - -const destCollName = "explain_max_time_ms_dest"; -const mapFn = function() { - emit(this.i, this.j); -}; -const reduceFn = function(key, values) { - return Array.sum(values); -}; - -coll.drop(); -assert.commandWorked(db.createCollection(collName)); - -assert.commandWorked(coll.insert({i: 1, j: 1})); -assert.commandWorked(coll.insert({i: 2, j: 1})); -assert.commandWorked(coll.insert({i: 2, j: 2})); - -// Set fail point to make sure operations with "maxTimeMS" set will time out. -assert.commandWorked( - db.adminCommand({configureFailPoint: "maxTimeAlwaysTimeOut", mode: "alwaysOn"})); - -for (const verbosity of ["executionStats", "allPlansExecution"]) { - // Expect explain to time out if "maxTimeMS" is set on the aggregate command. - assert.commandFailedWithCode(assert.throws(function() { - coll.explain(verbosity).aggregate( - [{$match: {i: 1}}], {maxTimeMS: 1}); - }), - ErrorCodes.MaxTimeMSExpired); - // Expect explain to time out if "maxTimeMS" is set on the count command. - assert.commandFailedWithCode(assert.throws(function() { - coll.explain(verbosity).count({i: 1}, - {maxTimeMS: 1}); - }), - ErrorCodes.MaxTimeMSExpired); - // Expect explain to time out if "maxTimeMS" is set on the distinct command. - assert.commandFailedWithCode(assert.throws(function() { - coll.explain(verbosity).distinct( - "i", {}, {maxTimeMS: 1}); - }), - ErrorCodes.MaxTimeMSExpired); - // Expect explain to time out if "maxTimeMS" is set on the find command. - assert.commandFailedWithCode(assert.throws(function() { - coll.find().maxTimeMS(1).explain(verbosity); - }), - ErrorCodes.MaxTimeMSExpired); - assert.commandFailedWithCode( - assert.throws(function() { - coll.explain(verbosity).find().maxTimeMS(1).finish(); - }), - ErrorCodes.MaxTimeMSExpired); - // Expect explain to time out if "maxTimeMS" is set on the findAndModify command. - assert.commandFailedWithCode(assert.throws(function() { - coll.explain(verbosity).findAndModify( - {update: {$inc: {j: 1}}, maxTimeMS: 1}); - }), - ErrorCodes.MaxTimeMSExpired); - // Expect explain to time out if "maxTimeMS" is set on the mapReduce command. - assert.commandFailedWithCode( - assert.throws(function() { - coll.explain(verbosity).mapReduce( - mapFn, reduceFn, {out: destCollName, maxTimeMS: 1}); - }), - ErrorCodes.MaxTimeMSExpired); -} - -// Disable fail point. -assert.commandWorked(db.adminCommand({configureFailPoint: "maxTimeAlwaysTimeOut", mode: "off"})); - -MongoRunner.stopMongod(standalone); -})(); diff --git a/src/mongo/shell/explain_query.js b/src/mongo/shell/explain_query.js index b4935fd07d4..c679683a421 100644 --- a/src/mongo/shell/explain_query.js +++ b/src/mongo/shell/explain_query.js @@ -151,11 +151,6 @@ var DBExplainQuery = (function() { var explainCmd = {explain: innerCmd}; explainCmd["verbosity"] = this._verbosity; - // If "maxTimeMS" is set on innerCmd, it needs to be propagated to the top-level - // of explainCmd so that it has the intended effect. - if (innerCmd.hasOwnProperty("maxTimeMS")) { - explainCmd.maxTimeMS = innerCmd.maxTimeMS; - } var explainDb = this._query._db; diff --git a/src/mongo/shell/explainable.js b/src/mongo/shell/explainable.js index c47c7fab7cd..08a900c5274 100644 --- a/src/mongo/shell/explainable.js +++ b/src/mongo/shell/explainable.js @@ -35,16 +35,6 @@ var Explainable = (function() { return explainResult; }; - var buildExplainCmd = function(innerCmd, verbosity) { - var explainCmd = {"explain": innerCmd, "verbosity": verbosity}; - // If "maxTimeMS" is set on innerCmd, it needs to be propagated to the top-level - // of explainCmd so that it has the intended effect. - if (innerCmd.hasOwnProperty("maxTimeMS")) { - explainCmd.maxTimeMS = innerCmd.maxTimeMS; - } - return explainCmd; - }; - function constructor(collection, verbosity) { // // Private vars. @@ -127,7 +117,7 @@ var Explainable = (function() { let aggCmd = Object.extend( {"aggregate": this._collection.getName(), "pipeline": pipeline}, extraOptsCopy); - let explainCmd = buildExplainCmd(aggCmd, this._verbosity); + let explainCmd = {"explain": aggCmd, "verbosity": this._verbosity}; let explainResult = this._collection.runReadCommand(explainCmd); return throwOrReturn(explainResult); } @@ -150,7 +140,7 @@ var Explainable = (function() { this.findAndModify = function(params) { var famCmd = Object.extend({"findAndModify": this._collection.getName()}, params); - var explainCmd = buildExplainCmd(famCmd, this._verbosity); + var explainCmd = {"explain": famCmd, "verbosity": this._verbosity}; var explainResult = this._collection.runReadCommand(explainCmd); return throwOrReturn(explainResult); }; @@ -165,11 +155,8 @@ var Explainable = (function() { if (options && options.hasOwnProperty("collation")) { distinctCmd.collation = options.collation; } - if (options && options.hasOwnProperty("maxTimeMS")) { - distinctCmd.maxTimeMS = options.maxTimeMS; - } - var explainCmd = buildExplainCmd(distinctCmd, this._verbosity); + var explainCmd = {explain: distinctCmd, verbosity: this._verbosity}; var explainResult = this._collection.runReadCommand(explainCmd); return throwOrReturn(explainResult); }; @@ -248,7 +235,7 @@ var Explainable = (function() { else Object.extend(mapReduceCmd, optionsObjOrOutString); - const explainCmd = buildExplainCmd(mapReduceCmd, this._verbosity); + const explainCmd = {"explain": mapReduceCmd, "verbosity": this._verbosity}; const explainResult = this._collection.runCommand(explainCmd); return throwOrReturn(explainResult); }; |