diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-09-25 17:19:31 -0400 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-09-26 11:57:13 -0400 |
commit | 411e9810075556fb196278a669fab0f19ea901ce (patch) | |
tree | 5cbb03a72f270aa3a8d6352004dbc072497f0424 | |
parent | 369164318a5e0c952f3de426a68c48078c64c60c (diff) | |
download | mongo-411e9810075556fb196278a669fab0f19ea901ce.tar.gz |
SERVER-20652 remove pseudocommand downconversion code in mongos
-rw-r--r-- | jstests/multiVersion/kill_op_pseudocommand.js | 69 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_current_op.cpp | 59 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_kill_op.cpp | 8 |
3 files changed, 3 insertions, 133 deletions
diff --git a/jstests/multiVersion/kill_op_pseudocommand.js b/jstests/multiVersion/kill_op_pseudocommand.js deleted file mode 100644 index 07954684204..00000000000 --- a/jstests/multiVersion/kill_op_pseudocommand.js +++ /dev/null @@ -1,69 +0,0 @@ -(function() { - "use strict"; - // Test that a 3.2 Mongos will correctly translate a killOp command - // to a killop pseudocommand when talking to an old shard - - // TODO: Remove after mongodb 3.2 is released - - // Sharded cluster - // -- latest mongos - // -- latest config - // -- one 3.0 shard - var options = { - mongosOptions: {binVersion: "3.1"}, - configOptions: {binVersion: "3.1"}, - shardOptions: {binVersion: "3.0"} - }; - - var st = new ShardingTest({name: "killOp-multiver", shards: 1, other: options}); - - var db = st.s.getDB("killOp-multiver"); - var db1 = db; - db.dropDatabase(); - assert.commandWorked(db.adminCommand({enableSharding: db.getName()})); - - var testCol = db.tc; - - // start long running op - testCol.insert({"foo": "bar"}); - jsTestLog("Starting long-running $where operation"); - - var start = new Date(); - - var parShell = startParallelShell( - 'db.getSiblingDB("killOp-multiver").tc.count( { $where: function() { while( 1 ) { ; } }})', - st.s.port); - var findOpId = function () { - var curOps = db.currentOp(); - var inProg = curOps.inprog; - var opId = null; - inProg.forEach(function(op) { - if ((op.active === true) && - (op.ns === "killOp-multiver.tc") && - (op.query.count === "tc")) { - - opId = op.opid; - } - }); - return opId; - }; - - var opToKill = null; - - do { - opToKill = findOpId() - sleep(25); - } while (opToKill === null); - - db.killOp(opToKill); - - var exitCode = parShell({checkExitSuccess: false}); // wait for query to end - assert.neq(0, exitCode, - "expected shell to exit abnormally due to JS execution being terminated"); - - var end = new Date(); - - // make sure the query didn't end due to js op timeout - assert.lt(diff, 30000, "Query was killed due to timeout - not killOp"); - st.stop(); -})(); diff --git a/src/mongo/s/commands/cluster_current_op.cpp b/src/mongo/s/commands/cluster_current_op.cpp index 28f1311ca40..6b35d491b11 100644 --- a/src/mongo/s/commands/cluster_current_op.cpp +++ b/src/mongo/s/commands/cluster_current_op.cpp @@ -51,7 +51,6 @@ const char kOpIdFieldName[] = "opid"; const char kClientFieldName[] = "client"; // awkward underscores used to make this visually distinct from kClientFieldName const char kClient_S_FieldName[] = "client_s"; -const char kLegacyInprogCollection[] = "$cmd.sys.inprog"; const char kCommandName[] = "currentOp"; @@ -72,64 +71,6 @@ public: return isAuthorized ? Status::OK() : Status(ErrorCodes::Unauthorized, "Unauthorized"); } - // TODO remove after 3.2 - BSONObj specialErrorHandler(const std::string& server, - const std::string& db, - const BSONObj& cmdObj, - const BSONObj& originalResult) const final { - // it is unfortunate that this logic needs to be duplicated from - // DBClientWithCommands::runPseudoCommand - // but I don't see a better way to do it without performing heart surgery on - // Future/CommandResponse. - - auto status = getStatusFromCommandResult(originalResult); - invariant(!status.isOK()); - - uassert(28629, - str::stream() << "Received bad " << kCommandName << " response from server " - << server << " got: " << originalResult, - status != ErrorCodes::CommandResultSchemaViolation); - - // getStatusFromCommandResult handles cooercing "no such command" into the right - // Status type - if (status == ErrorCodes::CommandNotFound) { - // fall back to the old inprog pseudo-command - NamespaceString pseudoCommandNss("admin", kLegacyInprogCollection); - BSONObj legacyResult; - - BSONObjBuilder legacyCommandBob; - - // need to exclude {currentOp: 1} - for (auto&& cmdElem : cmdObj) { - if (cmdElem.fieldNameStringData() != kCommandName) { - legacyCommandBob.append(cmdElem); - } - } - auto legacyCommand = legacyCommandBob.done(); - - try { - ScopedDbConnection conn(server); - legacyResult = conn->findOne(pseudoCommandNss.ns(), legacyCommand); - - } catch (const DBException& ex) { - // If there is a non-DBException exception the entire operation will be - // terminated, as that would be a programmer error. - - // We convert the exception to a BSONObj so that the ordinary - // failure path for RunOnAllShardsCommand will handle the failure - - // TODO: consider adding an exceptionToBSONObj utility? - BSONObjBuilder b; - b.append("errmsg", ex.toString()); - b.append("code", ex.getCode()); - return b.obj(); - } - return legacyResult; - } - // if the command failed for another reason then we don't retry it. - return originalResult; - } - void aggregateResults(const std::vector<ShardAndReply>& results, BSONObjBuilder& output) final { // Each shard responds with a document containing an array of subdocuments. // Each subdocument represents an operation running on that shard. diff --git a/src/mongo/s/commands/cluster_kill_op.cpp b/src/mongo/s/commands/cluster_kill_op.cpp index d99abb461f0..b370b31b87d 100644 --- a/src/mongo/s/commands/cluster_kill_op.cpp +++ b/src/mongo/s/commands/cluster_kill_op.cpp @@ -41,6 +41,7 @@ #include "mongo/db/audit.h" #include "mongo/db/auth/authorization_session.h" #include "mongo/db/commands.h" +#include "mongo/rpc/metadata.h" #include "mongo/s/client/shard.h" #include "mongo/s/client/shard_registry.h" #include "mongo/s/grid.h" @@ -114,12 +115,9 @@ public: result.append("shardid", opId); ScopedDbConnection conn(shard->getConnString()); - BSONObj cmdRes; - BSONObjBuilder argsBob; - argsBob.append("op", opId); - auto args = argsBob.done(); // intentionally ignore return value - that is how legacy killOp worked. - conn->runPseudoCommand("admin", "killOp", "$cmd.sys.killop", args, cmdRes); + conn->runCommandWithMetadata( + "admin", "killOp", rpc::makeEmptyMetadata(), BSON("killOp" << 1 << "op" << opId)); conn.done(); // The original behavior of killOp on mongos is to always return success, regardless of |