summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2016-11-09 14:39:47 -0500
committerCharlie Swanson <charlie.swanson@mongodb.com>2016-11-11 10:10:06 -0500
commitfd8c45213b0e43039e57b8bbe24c8e219c574a41 (patch)
tree11259d1fd0271362be264d61b12f73992abfcdf7
parentc48aafbff45ec234677c195b1e9c5f1fb02672e9 (diff)
downloadmongo-fd8c45213b0e43039e57b8bbe24c8e219c574a41.tar.gz
SERVER-26966 Remove dead legacy find/getMore up and downconversion
-rw-r--r--jstests/multiVersion/skip_version_upgrade.js62
-rw-r--r--src/mongo/executor/SConscript20
-rw-r--r--src/mongo/executor/connection_pool_asio.cpp4
-rw-r--r--src/mongo/executor/downconvert_find_and_getmore_commands.cpp279
-rw-r--r--src/mongo/executor/downconvert_find_and_getmore_commands.h81
-rw-r--r--src/mongo/executor/network_interface_asio.h27
-rw-r--r--src/mongo/executor/network_interface_asio_auth.cpp3
-rw-r--r--src/mongo/executor/network_interface_asio_command.cpp25
-rw-r--r--src/mongo/executor/network_interface_asio_operation.cpp40
9 files changed, 76 insertions, 465 deletions
diff --git a/jstests/multiVersion/skip_version_upgrade.js b/jstests/multiVersion/skip_version_upgrade.js
new file mode 100644
index 00000000000..1c40bdda9e2
--- /dev/null
+++ b/jstests/multiVersion/skip_version_upgrade.js
@@ -0,0 +1,62 @@
+/**
+ * Tests that a mongod on the latest version will refuse to sync from a 3.0 node.
+ */
+(function() {
+ "use strict";
+
+ //
+ // Test that the latest version cannot replicate from a 3.0 node.
+ //
+ var rst = new ReplSetTest({nodes: [{binVersion: "3.0"}, {binVersion: "latest"}]});
+ rst.startSet();
+
+ // Make sure the 3.0 node will be elected.
+ var replSetConfig = rst.getReplSetConfig();
+ replSetConfig.members[0].priority = 1;
+ replSetConfig.members[1].priority = 0;
+ var threeZeroAdminDB = rst.nodes[0].getDB("admin");
+ var latestAdminDB = rst.nodes[1].getDB("admin");
+ assert.commandWorked(threeZeroAdminDB.runCommand({replSetInitiate: replSetConfig}));
+ assert.soon(
+ function() {
+ try {
+ latestAdminDB.runCommand({ping: 1});
+ } catch (e) {
+ return true;
+ }
+ return false;
+ },
+ "Expected latest node to terminate when communicating to node which does not support find" +
+ " commands, but it didn't.");
+
+ rst.stopSet(undefined, undefined, {allowedExitCodes: [MongoRunner.EXIT_ABRUPT]});
+
+ //
+ // Test that a 3.0 node cannot replicate off the latest node if that node is launched with the
+ // default featureCompatibilityVersion.
+ //
+ rst = new ReplSetTest({nodes: [{binVersion: "latest"}]});
+ rst.startSet();
+
+ // Configure the set to use protocol version 0 so that a 3.0 node can participate.
+ replSetConfig = rst.getReplSetConfig();
+ replSetConfig.protocolVersion = 0;
+ rst.initiate(replSetConfig);
+
+ // Add the node, but don't wait for it to start up, since we don't expect it to ever get to
+ // state SECONDARY.
+ rst.add({binVersion: "3.0"});
+
+ // Rig the election so that the first node running latest version remains the primary after the
+ // 3.0 secondary is added to the replica set.
+ replSetConfig = rst.getReplSetConfig();
+ replSetConfig.version = 2;
+ replSetConfig.members[1].priority = 0;
+
+ assert.commandWorked(rst.getPrimary().adminCommand({replSetReconfig: replSetConfig}));
+
+ // Verify that the 3.0 node cannot participate in the set. It should eventually exceed the
+ // maximum number of retries for initial sync and fail.
+ rst.waitForState(rst.nodes, [ReplSetTest.State.SECONDARY, ReplSetTest.State.DOWN]);
+ rst.stopSet(undefined, undefined, {allowedExitCodes: [MongoRunner.EXIT_ABRUPT]});
+})();
diff --git a/src/mongo/executor/SConscript b/src/mongo/executor/SConscript
index 25089c56334..000d751ecde 100644
--- a/src/mongo/executor/SConscript
+++ b/src/mongo/executor/SConscript
@@ -142,6 +142,7 @@ env.Library(
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/base/system_error',
+ '$BUILD_DIR/mongo/client/client_query',
'$BUILD_DIR/mongo/db/auth/authcommon',
'$BUILD_DIR/mongo/db/commands/test_commands_enabled',
'$BUILD_DIR/mongo/db/wire_version',
@@ -151,7 +152,6 @@ env.Library(
'async_stream',
'async_timer_asio',
'connection_pool',
- 'downconvert_find_and_getmore_commands',
'network_interface',
'task_executor_interface',
])
@@ -317,24 +317,6 @@ env.CppUnitTest(
)
env.Library(
- target='downconvert_find_and_getmore_commands',
- source=[
- 'downconvert_find_and_getmore_commands.cpp',
- ],
- LIBDEPS=[
- 'remote_command',
- '$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/client/client_query',
- '$BUILD_DIR/mongo/db/query/command_request_response',
- '$BUILD_DIR/mongo/db/query/command_request_response',
- '$BUILD_DIR/mongo/db/query/query_request',
- '$BUILD_DIR/mongo/rpc/protocol',
- '$BUILD_DIR/mongo/rpc/metadata',
- '$BUILD_DIR/mongo/util/net/network',
- ],
-)
-
-env.Library(
target='task_executor_pool',
source=[
'task_executor_pool.cpp',
diff --git a/src/mongo/executor/connection_pool_asio.cpp b/src/mongo/executor/connection_pool_asio.cpp
index 0788a67d7f6..b5f4f803793 100644
--- a/src/mongo/executor/connection_pool_asio.cpp
+++ b/src/mongo/executor/connection_pool_asio.cpp
@@ -272,9 +272,7 @@ void ASIOConnection::refresh(Milliseconds timeout, RefreshCallback cb) {
setTimeout(timeout, [this] { _impl->connection().stream().cancel(); });
// Our pings are isMaster's
- auto beginStatus = op->beginCommand(makeIsMasterRequest(this),
- NetworkInterfaceASIO::AsyncCommand::CommandType::kRPC,
- _hostAndPort);
+ auto beginStatus = op->beginCommand(makeIsMasterRequest(this), _hostAndPort);
if (!beginStatus.isOK()) {
auto cb = std::move(_refreshCallback);
cb(this, beginStatus);
diff --git a/src/mongo/executor/downconvert_find_and_getmore_commands.cpp b/src/mongo/executor/downconvert_find_and_getmore_commands.cpp
deleted file mode 100644
index 7d1aa15c817..00000000000
--- a/src/mongo/executor/downconvert_find_and_getmore_commands.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-/**
- * Copyright (C) 2015 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/executor/downconvert_find_and_getmore_commands.h"
-
-#include <memory>
-#include <string>
-#include <tuple>
-
-#include "mongo/base/data_range_cursor.h"
-#include "mongo/base/data_type_validated.h"
-#include "mongo/base/status_with.h"
-#include "mongo/client/constants.h"
-#include "mongo/client/dbclientinterface.h"
-#include "mongo/db/cursor_id.h"
-#include "mongo/db/namespace_string.h"
-#include "mongo/db/query/cursor_response.h"
-#include "mongo/db/query/getmore_request.h"
-#include "mongo/executor/remote_command_request.h"
-#include "mongo/executor/remote_command_response.h"
-#include "mongo/rpc/get_status_from_command_result.h"
-#include "mongo/rpc/metadata/server_selection_metadata.h"
-#include "mongo/rpc/object_check.h"
-#include "mongo/util/assert_util.h"
-#include "mongo/util/net/message.h"
-
-namespace mongo {
-namespace executor {
-
-namespace {
-
-StatusWith<std::tuple<CursorId, BSONArray>> getBatchFromReply(std::int32_t requestId,
- const Message& response) {
- auto header = response.header();
- if (header.getNetworkOp() != mongo::opReply) {
- return {ErrorCodes::ProtocolError,
- str::stream() << "Expected to be decoding an OP_REPLY but got "
- << mongo::networkOpToString(header.getNetworkOp())};
- }
-
- if (header.getResponseToMsgId() != requestId) {
- return {ErrorCodes::ProtocolError,
- str::stream() << "responseTo field of OP_REPLY header with value '"
- << header.getResponseToMsgId()
- << "' does not match requestId '"
- << requestId
- << "'"};
- }
-
- if ((header.dataLen() < 0) ||
- (static_cast<std::size_t>(header.dataLen()) > mongo::MaxMessageSizeBytes)) {
- return {ErrorCodes::InvalidLength,
- str::stream() << "Received message has invalid length field with value "
- << header.dataLen()};
- }
-
- QueryResult::View qr = response.header().view2ptr();
-
- auto resultFlags = qr.getResultFlags();
-
- if (resultFlags & ResultFlag_CursorNotFound) {
- return {ErrorCodes::CursorNotFound,
- str::stream() << "Cursor with id '" << qr.getCursorId() << "' not found"};
- }
-
- // Use CDRC directly instead of DocumentRange as DocumentRange has a throwing API.
- ConstDataRangeCursor cdrc{qr.data(), qr.data() + header.dataLen()};
-
- if (resultFlags & ResultFlag_ErrSet) {
- if (qr.getNReturned() != 1) {
- return {ErrorCodes::BadValue,
- str::stream() << "ResultFlag_ErrSet flag set on reply, but nReturned was '"
- << qr.getNReturned()
- << "' - expected 1"};
- }
- // Convert error document to a Status.
- // Will throw if first document is invalid BSON.
- auto first = cdrc.readAndAdvance<Validated<BSONObj>>();
- if (!first.isOK()) {
- return first.getStatus();
- }
-
- // Convert error document to a status.
- return getStatusFromCommandResult(first.getValue());
- }
-
- Validated<BSONObj> nextObj;
- BSONArrayBuilder batch;
- while (!cdrc.empty() && batch.arrSize() < qr.getNReturned()) {
- auto readStatus = cdrc.readAndAdvance(&nextObj);
- if (!readStatus.isOK()) {
- return readStatus;
- }
- batch.append(nextObj.val);
- }
- if (qr.getNReturned() != batch.arrSize()) {
- return {ErrorCodes::InvalidLength,
- str::stream() << "Count of documents in OP_REPLY message (" << batch.arrSize()
- << ") did not match the value specified in the nReturned field ("
- << qr.getNReturned()
- << ")"};
- }
-
- return {std::make_tuple(qr.getCursorId(), batch.arr())};
-}
-
-} // namespace
-
-StatusWith<Message> downconvertFindCommandRequest(const RemoteCommandRequest& request) {
- const auto& cmdObj = request.cmdObj;
- const NamespaceString nss(request.dbname, cmdObj.firstElement().String());
- if (!nss.isValid()) {
- return {ErrorCodes::InvalidNamespace,
- str::stream() << "Invalid collection name: " << nss.ns()};
- }
-
- const std::string& ns = nss.ns();
-
- // It is a little heavy handed to use QueryRequest to convert the command object to
- // query() arguments but we get validation and consistent behavior with the find
- // command implementation on the remote server.
- auto qrStatus = QueryRequest::makeFromFindCommand(nss, cmdObj, false);
- if (!qrStatus.isOK()) {
- return qrStatus.getStatus();
- }
-
- auto qr = std::move(qrStatus.getValue());
-
- // We are downconverting a find command, and find command can only have ntoreturn
- // if it was generated by mongos.
- invariant(!qr->getNToReturn());
- Query query(qr->getFilter());
- if (!qr->getSort().isEmpty()) {
- query.sort(qr->getSort());
- }
- if (!qr->getHint().isEmpty()) {
- query.hint(qr->getHint());
- }
- if (!qr->getMin().isEmpty()) {
- query.minKey(qr->getMin());
- }
- if (!qr->getMax().isEmpty()) {
- query.minKey(qr->getMax());
- }
- if (qr->isExplain()) {
- query.explain();
- }
- if (qr->isSnapshot()) {
- query.snapshot();
- }
-
- const int nToReturn = qr->getLimit().value_or(0) * -1;
- const int nToSkip = qr->getSkip().value_or(0);
- const BSONObj* fieldsToReturn = &qr->getProj();
- int queryOptions = qr->getOptions(); // non-const so we can set slaveOk if we need to
- const int batchSize = qr->getBatchSize().value_or(0);
-
- const int nextBatchSize = [batchSize, nToReturn]() {
- if (nToReturn == 0)
- return batchSize;
- if (batchSize == 0)
- return nToReturn;
- return batchSize < nToReturn ? batchSize : nToReturn;
- }();
-
- // We can't downconvert all metadata, since we aren't sending a command, but we do need to
- // downconvert $secondaryOk to the slaveOK bit.
- auto ssm = rpc::ServerSelectionMetadata::readFromMetadata(
- request.metadata.getField(rpc::ServerSelectionMetadata::fieldName()));
- if (!ssm.isOK()) {
- return ssm.getStatus();
- }
- if (ssm.getValue().isSecondaryOk()) {
- queryOptions |= mongo::QueryOption_SlaveOk;
- }
-
- Message message;
- assembleQueryRequest(
- ns, query.obj, nextBatchSize, nToSkip, fieldsToReturn, queryOptions, message);
-
- return {std::move(message)};
-}
-
-RemoteCommandResponse upconvertLegacyQueryResponse(std::int32_t requestId,
- StringData cursorNamespace,
- const Message& response) {
- auto swBatch = getBatchFromReply(requestId, response);
- if (!swBatch.isOK()) {
- return {swBatch.getStatus()};
- }
-
- BSONArray batch;
- CursorId cursorId;
- std::tie(cursorId, batch) = std::move(swBatch.getValue());
-
- BSONObjBuilder result;
- appendCursorResponseObject(cursorId, cursorNamespace, std::move(batch), &result);
- // Using Command::appendCommandStatus would create a circular dep, so it's simpler to just do
- // this.
- result.append("ok", 1.0);
-
- RemoteCommandResponse upconvertedResponse;
- upconvertedResponse.data = result.obj();
-
- return upconvertedResponse;
-}
-
-StatusWith<Message> downconvertGetMoreCommandRequest(const RemoteCommandRequest& request) {
- auto swGetMoreRequest = GetMoreRequest::parseFromBSON(request.dbname, request.cmdObj);
- if (!swGetMoreRequest.isOK()) {
- return swGetMoreRequest.getStatus();
- }
-
- auto getMoreRequest = std::move(swGetMoreRequest.getValue());
-
- BufBuilder b;
- b.appendNum(std::int32_t{0}); // reserved bits
- b.appendStr(getMoreRequest.nss.ns());
- // Without this static cast, we will append batchSize as an int64 and get an invalid message.
- b.appendNum(static_cast<std::int32_t>(getMoreRequest.batchSize.value_or(0)));
- b.appendNum(getMoreRequest.cursorid);
- Message m;
- m.setData(dbGetMore, b.buf(), b.len());
-
- return {std::move(m)};
-}
-
-RemoteCommandResponse upconvertLegacyGetMoreResponse(std::int32_t requestId,
- StringData cursorNamespace,
- const Message& response) {
- auto swBatch = getBatchFromReply(requestId, response);
- if (!swBatch.isOK()) {
- return {swBatch.getStatus()};
- }
-
- BSONArray batch;
- CursorId cursorId;
-
- std::tie(cursorId, batch) = std::move(swBatch.getValue());
-
- BSONObjBuilder result;
- appendGetMoreResponseObject(cursorId, cursorNamespace, std::move(batch), &result);
- result.append("ok", 1.0);
-
- RemoteCommandResponse resp;
- resp.data = result.obj();
-
- return resp;
-}
-
-} // namespace mongo
-} // namespace executor
diff --git a/src/mongo/executor/downconvert_find_and_getmore_commands.h b/src/mongo/executor/downconvert_find_and_getmore_commands.h
deleted file mode 100644
index dd991358e78..00000000000
--- a/src/mongo/executor/downconvert_find_and_getmore_commands.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright (C) 2015 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include <cstdint>
-#include <memory>
-
-namespace mongo {
-
-class Message;
-
-template <typename T>
-class StatusWith;
-
-class StringData;
-class NamespaceString;
-
-namespace executor {
-struct RemoteCommandRequest;
-struct RemoteCommandResponse;
-
-/**
- * Downconverts a find command request to the legacy (non-command) OP_QUERY format. The returned
- * message is formed, with the exception of the messageId header field, which must be set by
- * the caller before sending the message over the wire. Note that our legacy socket code sets the
- * messageId in MessagingPort::say().
- */
-StatusWith<Message> downconvertFindCommandRequest(const RemoteCommandRequest& request);
-
-/**
- * Upconverts the OP_REPLY received in response to a legacy OP_QUERY to a semantically equivalent
- * find command response. The 'requestId' parameter is the messageId of the original OP_QUERY, and
- * the 'cursorNamespace' is the full namespace of the collection the query ran on.
- */
-RemoteCommandResponse upconvertLegacyQueryResponse(std::int32_t requestId,
- StringData cursorNamespace,
- const Message& response);
-
-/**
- * Downconverts a getMore command request to the legacy OP_GET_MORE format. The returned message
- * is fully formed, with the exception of the messageId header field, which must be set by the
- * the caller before sending the message over the wire. Note that our legacy socket code sets the
- * messageId in MessagingPort::say().
- */
-StatusWith<Message> downconvertGetMoreCommandRequest(const RemoteCommandRequest& request);
-
-/**
- * Upconverts the OP_REPLY received in response to a legacy OP_GET_MORE to a semantically equivalent
- * getMore command response. The 'requestId' parameter is the messageId of the original OP_GET_MORE,
- * and the 'curesorNamespace' is the full namespace of the collection the original query ran on.
- */
-RemoteCommandResponse upconvertLegacyGetMoreResponse(std::int32_t requestId,
- StringData cursorNamespace,
- const Message& response);
-
-} // namespace mongo
-} // namespace executor
diff --git a/src/mongo/executor/network_interface_asio.h b/src/mongo/executor/network_interface_asio.h
index 3d7aa2f1445..3fcd2e42771 100644
--- a/src/mongo/executor/network_interface_asio.h
+++ b/src/mongo/executor/network_interface_asio.h
@@ -183,28 +183,7 @@ private:
*/
class AsyncCommand {
public:
- /**
- * Describes the variant of AsyncCommand this object represents.
- */
- enum class CommandType {
- /**
- * An ordinary command of an unspecified Protocol.
- */
- kRPC,
-
- /**
- * A 'find' command that has been downconverted to an OP_QUERY.
- */
- kDownConvertedFind,
-
- /**
- * A 'getMore' command that has been downconverted to an OP_GET_MORE.
- */
- kDownConvertedGetMore,
- };
-
AsyncCommand(AsyncConnection* conn,
- CommandType type,
Message&& command,
Date_t now,
const HostAndPort& target);
@@ -223,8 +202,6 @@ private:
private:
NetworkInterfaceASIO::AsyncConnection* const _conn;
- const CommandType _type;
-
Message _toSend;
Message _toRecv;
@@ -305,9 +282,7 @@ private:
// This form of beginCommand takes a raw message. It is needed if the caller
// has to form the command manually (e.g. to use a specific requestBuilder).
- Status beginCommand(Message&& newCommand,
- AsyncCommand::CommandType,
- const HostAndPort& target);
+ Status beginCommand(Message&& newCommand, const HostAndPort& target);
AsyncCommand* command();
diff --git a/src/mongo/executor/network_interface_asio_auth.cpp b/src/mongo/executor/network_interface_asio_auth.cpp
index 921262f2875..84600d6bde6 100644
--- a/src/mongo/executor/network_interface_asio_auth.cpp
+++ b/src/mongo/executor/network_interface_asio_auth.cpp
@@ -88,8 +88,7 @@ void NetworkInterfaceASIO::_runIsMaster(AsyncOp* op) {
requestBuilder.setMetadata(rpc::makeEmptyMetadata());
// Set current command to ismaster request and run
- auto beginStatus = op->beginCommand(
- requestBuilder.done(), AsyncCommand::CommandType::kRPC, op->request().target);
+ auto beginStatus = op->beginCommand(requestBuilder.done(), op->request().target);
if (!beginStatus.isOK()) {
return _completeOperation(op, beginStatus);
}
diff --git a/src/mongo/executor/network_interface_asio_command.cpp b/src/mongo/executor/network_interface_asio_command.cpp
index 4c981ff41e0..036b2954ee0 100644
--- a/src/mongo/executor/network_interface_asio_command.cpp
+++ b/src/mongo/executor/network_interface_asio_command.cpp
@@ -40,7 +40,6 @@
#include "mongo/executor/async_stream_interface.h"
#include "mongo/executor/async_stream_interface.h"
#include "mongo/executor/connection_pool_asio.h"
-#include "mongo/executor/downconvert_find_and_getmore_commands.h"
#include "mongo/rpc/factory.h"
#include "mongo/rpc/metadata/metadata_hook.h"
#include "mongo/rpc/protocol.h"
@@ -177,11 +176,10 @@ ResponseStatus decodeRPC(Message* received,
} // namespace
NetworkInterfaceASIO::AsyncCommand::AsyncCommand(AsyncConnection* conn,
- CommandType type,
Message&& command,
Date_t now,
const HostAndPort& target)
- : _conn(conn), _type(type), _toSend(std::move(command)), _start(now), _target(target) {
+ : _conn(conn), _toSend(std::move(command)), _start(now), _target(target) {
_toSend.header().setResponseToMsgId(0);
}
@@ -214,23 +212,10 @@ ResponseStatus NetworkInterfaceASIO::AsyncCommand::response(AsyncOp* op,
received = std::move(swm.getValue());
}
- switch (_type) {
- case CommandType::kRPC: {
- auto rs = decodeRPC(&received, protocol, now - _start, _target, metadataHook);
- if (rs.isOK())
- op->setResponseMetadata(rs.metadata);
- return rs;
- }
- case CommandType::kDownConvertedFind: {
- auto ns = DbMessage(_toSend).getns();
- return upconvertLegacyQueryResponse(_toSend.header().getId(), ns, received);
- }
- case CommandType::kDownConvertedGetMore: {
- auto ns = DbMessage(_toSend).getns();
- return upconvertLegacyGetMoreResponse(_toSend.header().getId(), ns, received);
- }
- }
- MONGO_UNREACHABLE;
+ auto rs = decodeRPC(&received, protocol, now - _start, _target, metadataHook);
+ if (rs.isOK())
+ op->setResponseMetadata(rs.metadata);
+ return rs;
}
void NetworkInterfaceASIO::_startCommand(AsyncOp* op) {
diff --git a/src/mongo/executor/network_interface_asio_operation.cpp b/src/mongo/executor/network_interface_asio_operation.cpp
index d595df6c6e8..f56c3be6e16 100644
--- a/src/mongo/executor/network_interface_asio_operation.cpp
+++ b/src/mongo/executor/network_interface_asio_operation.cpp
@@ -37,7 +37,6 @@
#include "mongo/db/query/query_request.h"
#include "mongo/executor/async_stream_interface.h"
#include "mongo/executor/connection_pool_asio.h"
-#include "mongo/executor/downconvert_find_and_getmore_commands.h"
#include "mongo/executor/network_interface_asio.h"
#include "mongo/rpc/factory.h"
#include "mongo/rpc/metadata/metadata_hook.h"
@@ -164,7 +163,6 @@ void NetworkInterfaceASIO::AsyncOp::setConnection(AsyncConnection&& conn) {
}
Status NetworkInterfaceASIO::AsyncOp::beginCommand(Message&& newCommand,
- AsyncCommand::CommandType type,
const HostAndPort& target) {
// NOTE: We operate based on the assumption that AsyncOp's
// AsyncConnection does not change over its lifetime.
@@ -176,44 +174,16 @@ Status NetworkInterfaceASIO::AsyncOp::beginCommand(Message&& newCommand,
return swm.getStatus();
// Construct a new AsyncCommand object for each command.
- _command.emplace(_connection.get_ptr(), type, std::move(swm.getValue()), _owner->now(), target);
+ _command.emplace(_connection.get_ptr(), std::move(swm.getValue()), _owner->now(), target);
return Status::OK();
}
Status NetworkInterfaceASIO::AsyncOp::beginCommand(const RemoteCommandRequest& request) {
- // Check if we need to downconvert find or getMore commands.
- StringData commandName = request.cmdObj.firstElement().fieldNameStringData();
- const auto isFindCmd = commandName == QueryRequest::kFindCommandName;
- const auto isGetMoreCmd = commandName == GetMoreRequest::kGetMoreCommandName;
- const auto isFindOrGetMoreCmd = isFindCmd || isGetMoreCmd;
-
- // If we aren't sending a find or getMore, or the server supports OP_COMMAND we don't have
- // to worry about downconversion.
- if (!isFindOrGetMoreCmd || connection().serverProtocols() == rpc::supports::kAll) {
- auto newCommand = messageFromRequest(request, operationProtocol());
- if (!newCommand.isOK()) {
- return newCommand.getStatus();
- }
- return beginCommand(
- std::move(newCommand.getValue()), AsyncCommand::CommandType::kRPC, request.target);
- } else if (isFindCmd) {
- auto downconvertedFind = downconvertFindCommandRequest(request);
- if (!downconvertedFind.isOK()) {
- return downconvertedFind.getStatus();
- }
- return beginCommand(std::move(downconvertedFind.getValue()),
- AsyncCommand::CommandType::kDownConvertedFind,
- request.target);
- } else {
- MONGO_ASYNC_OP_INVARIANT(isGetMoreCmd, "Expected a GetMore command");
- auto downconvertedGetMore = downconvertGetMoreCommandRequest(request);
- if (!downconvertedGetMore.isOK()) {
- return downconvertedGetMore.getStatus();
- }
- return beginCommand(std::move(downconvertedGetMore.getValue()),
- AsyncCommand::CommandType::kDownConvertedGetMore,
- request.target);
+ auto newCommand = messageFromRequest(request, operationProtocol());
+ if (!newCommand.isOK()) {
+ return newCommand.getStatus();
}
+ return beginCommand(std::move(newCommand.getValue()), request.target);
}
NetworkInterfaceASIO::AsyncCommand* NetworkInterfaceASIO::AsyncOp::command() {