diff options
20 files changed, 605 insertions, 91 deletions
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp index a25288efa8e..9c85905833c 100644 --- a/src/mongo/db/commands/dbcommands.cpp +++ b/src/mongo/db/commands/dbcommands.cpp @@ -96,6 +96,7 @@ #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" #include "mongo/rpc/metadata/sharding_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/rpc/reply_builder_interface.h" #include "mongo/rpc/request_interface.h" #include "mongo/s/chunk_version.h" @@ -1210,6 +1211,7 @@ void Command::execCommand(OperationContext* txn, // TODO: move this back to runCommands when mongos supports OperationContext // see SERVER-18515 for details. uassertStatusOK(rpc::readRequestMetadata(txn, request.getMetadata())); + rpc::TrackingMetadata::get(txn).initWithOperName(command->getName()); dassert(replyBuilder->getState() == rpc::ReplyBuilderInterface::State::kCommandReply); @@ -1348,6 +1350,13 @@ void Command::execCommand(OperationContext* txn, command->_commandsExecuted.increment(); + if (logger::globalLogDomain()->shouldLog(logger::LogComponent::kTracking, + logger::LogSeverity::Debug(1)) && + rpc::TrackingMetadata::get(txn).getParentOperId()) { + MONGO_LOG_COMPONENT(1, logger::LogComponent::kTracking) + << rpc::TrackingMetadata::get(txn).toString(); + rpc::TrackingMetadata::get(txn).setIsLogged(true); + } retval = command->run(txn, request, replyBuilder); dassert(replyBuilder->getState() == rpc::ReplyBuilderInterface::State::kOutputDocs); diff --git a/src/mongo/logger/log_component.cpp b/src/mongo/logger/log_component.cpp index 1599a05aaad..ca1e5e73d78 100644 --- a/src/mongo/logger/log_component.cpp +++ b/src/mongo/logger/log_component.cpp @@ -119,6 +119,8 @@ StringData LogComponent::toStringData() const { return "asio"_sd; case kBridge: return "bridge"_sd; + case kTracking: + return "tracking"_sd; case kNumLogComponents: return "total"_sd; // No default. Compiler should complain if there's a log component that's not handled. @@ -189,6 +191,8 @@ StringData LogComponent::getNameForLog() const { return "ASIO "_sd; case kBridge: return "BRIDGE "_sd; + case kTracking: + return "TRACKING"_sd; case kNumLogComponents: return "TOTAL "_sd; // No default. Compiler should complain if there's a log component that's not handled. diff --git a/src/mongo/logger/log_component.h b/src/mongo/logger/log_component.h index 6a28190353f..28645bf2c4e 100644 --- a/src/mongo/logger/log_component.h +++ b/src/mongo/logger/log_component.h @@ -60,6 +60,7 @@ public: kFTDC, kASIO, kBridge, + kTracking, kNumLogComponents }; diff --git a/src/mongo/rpc/SConscript b/src/mongo/rpc/SConscript index fcd14efee87..b049a69e2ff 100644 --- a/src/mongo/rpc/SConscript +++ b/src/mongo/rpc/SConscript @@ -150,6 +150,7 @@ env.Library( 'metadata/server_selection_metadata.cpp', 'metadata/sharding_metadata.cpp', 'metadata/repl_set_metadata.cpp', + 'metadata/tracking_metadata.cpp', ], LIBDEPS=[ 'client_metadata', @@ -168,6 +169,7 @@ env.CppUnitTest( source=[ 'metadata/server_selection_metadata_test.cpp', 'metadata/sharding_metadata_test.cpp', + 'metadata/tracking_metadata_test.cpp', ], LIBDEPS=[ 'metadata', diff --git a/src/mongo/rpc/metadata.cpp b/src/mongo/rpc/metadata.cpp index d286ece26ca..00a9d58dc9f 100644 --- a/src/mongo/rpc/metadata.cpp +++ b/src/mongo/rpc/metadata.cpp @@ -37,6 +37,7 @@ #include "mongo/rpc/metadata/config_server_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" #include "mongo/rpc/metadata/sharding_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" namespace mongo { namespace rpc { @@ -49,6 +50,7 @@ Status readRequestMetadata(OperationContext* txn, const BSONObj& metadataObj) { BSONElement ssmElem; BSONElement auditElem; BSONElement configSvrElem; + BSONElement trackingElem; BSONElement clientElem; for (const auto& metadataElem : metadataObj) { @@ -61,6 +63,8 @@ Status readRequestMetadata(OperationContext* txn, const BSONObj& metadataObj) { configSvrElem = metadataElem; } else if (fieldName == ClientMetadata::fieldName()) { clientElem = metadataElem; + } else if (fieldName == TrackingMetadata::fieldName()) { + trackingElem = metadataElem; } } @@ -88,6 +92,12 @@ Status readRequestMetadata(OperationContext* txn, const BSONObj& metadataObj) { } ConfigServerMetadata::get(txn) = std::move(configServerMetadata.getValue()); + auto trackingMetadata = TrackingMetadata::readFromMetadata(trackingElem); + if (!trackingMetadata.isOK()) { + return trackingMetadata.getStatus(); + } + TrackingMetadata::get(txn) = std::move(trackingMetadata.getValue()); + return Status::OK(); } diff --git a/src/mongo/rpc/metadata/tracking_metadata.cpp b/src/mongo/rpc/metadata/tracking_metadata.cpp new file mode 100644 index 00000000000..efe2cbf50e0 --- /dev/null +++ b/src/mongo/rpc/metadata/tracking_metadata.cpp @@ -0,0 +1,156 @@ +/** + * Copyright (C) 2016 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/rpc/metadata/tracking_metadata.h" + +#include "mongo/bson/util/bson_check.h" +#include "mongo/bson/util/bson_extract.h" +#include "mongo/db/jsobj.h" +#include "mongo/rpc/metadata.h" + +namespace mongo { +namespace rpc { + +namespace { + +const char kOperIdFieldName[] = "operId"; +const char kOperNameFieldName[] = "operName"; +const char kParentOperIdFieldName[] = "parentOperId"; + +} // unnamed namespace + +const OperationContext::Decoration<TrackingMetadata> TrackingMetadata::get = + OperationContext::declareDecoration<TrackingMetadata>(); + +TrackingMetadata::TrackingMetadata(OID operId, std::string operName) + : _operId(std::move(operId)), _operName(std::move(operName)) {} + +TrackingMetadata::TrackingMetadata(OID operId, std::string operName, std::string parentOperId) + : _operId(std::move(operId)), + _operName(std::move(operName)), + _parentOperId(std::move(parentOperId)) {} + +StatusWith<TrackingMetadata> TrackingMetadata::readFromMetadata(const BSONObj& metadataObj) { + return readFromMetadata(metadataObj.getField(fieldName())); +} + +void TrackingMetadata::initWithOperName(const std::string& name) { + // _operId to be already initialized if it was created with constructChildMetadata. + if (!_operId) { + OID operId; + operId.init(); + _operId = operId; + } + _operName = name; +} + +std::string TrackingMetadata::toString() const { + invariant(_operId); + invariant(_operName); + std::ostringstream stream; + if (_parentOperId) { + stream << "Cmd: " << *_operName << ", TrackingId: " << *_parentOperId << "|" << *_operId; + } else { + stream << "Cmd: " << *_operName << ", TrackingId: " << *_operId; + } + return stream.str(); +} + +TrackingMetadata TrackingMetadata::constructChildMetadata() const { + OID newOperId; + newOperId.init(); + std::string newParentOperId = + _parentOperId ? *_parentOperId + "|" + _operId->toString() : _operId->toString(); + + return TrackingMetadata(newOperId, std::string(), newParentOperId); +} + +StatusWith<TrackingMetadata> TrackingMetadata::readFromMetadata(const BSONElement& metadataElem) { + if (metadataElem.eoo()) { + return TrackingMetadata{}; + } else if (metadataElem.type() != mongo::Object) { + return {ErrorCodes::TypeMismatch, + str::stream() << "TrackingMetadata element has incorrect type: expected" + << mongo::Object + << " but got " + << metadataElem.type()}; + } + + BSONObj metadataObj = metadataElem.Obj(); + + OID operId; + auto status = bsonExtractOIDField(metadataObj, kOperIdFieldName, &operId); + if (!status.isOK()) { + return status; + } + + std::string operName; + status = bsonExtractStringField(metadataObj, kOperNameFieldName, &operName); + if (!status.isOK()) { + return status; + } + + std::string parentOperId; + status = bsonExtractStringField(metadataObj, kParentOperIdFieldName, &parentOperId); + if (!status.isOK()) { + if (status != ErrorCodes::NoSuchKey) { + return status; + } + return TrackingMetadata(std::move(operId), std::move(operName)); + } + + return TrackingMetadata(std::move(operId), std::move(operName), std::move(parentOperId)); +} + +void TrackingMetadata::writeToMetadata(BSONObjBuilder* builder) const { + BSONObjBuilder metadataBuilder(builder->subobjStart(fieldName())); + + invariant(_operId); + invariant(_operName); + metadataBuilder.append(kOperIdFieldName, *_operId); + metadataBuilder.append(kOperNameFieldName, *_operName); + + if (_parentOperId) { + metadataBuilder.append(kParentOperIdFieldName, *_parentOperId); + } +} + +BSONObj TrackingMetadata::removeTrackingData(BSONObj metadata) { + BSONObjBuilder builder; + for (auto elem : metadata) { + if (elem.fieldNameStringData() != rpc::TrackingMetadata::fieldName()) { + builder.append(elem); + } + } + return builder.obj(); +} + +} // namespace rpc +} // namespace mongo diff --git a/src/mongo/rpc/metadata/tracking_metadata.h b/src/mongo/rpc/metadata/tracking_metadata.h new file mode 100644 index 00000000000..3fdbac60c37 --- /dev/null +++ b/src/mongo/rpc/metadata/tracking_metadata.h @@ -0,0 +1,142 @@ +/** + * Copyright (C) 2016 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. + */ + +#pragma once + +#include "mongo/db/jsobj.h" +#include "mongo/db/operation_context.h" + +namespace mongo { + +class BSONObj; +class BSONObjBuilder; + +namespace rpc { + +/** + * This class encapsulates the metadata sent on every command request and response, + * containing data to track command execution. The current implementation only applies to commands + * that go through ShardRemote, which is most sharding catalog operations. It excludes the entire + * replication subsystem, query-type client commands, and write-type client commands. + * + * format: + * tracking_info: { + * operId: ObjectId("") // unique ID for the current operation + * operName: string // command name of the current operation + * parentOperId: string // '|' separated chain of the ancestor commands, oldest first + * } + */ +class TrackingMetadata { +public: + static const OperationContext::Decoration<TrackingMetadata> get; + + TrackingMetadata() = default; + explicit TrackingMetadata(OID operId, std::string operName); + explicit TrackingMetadata(OID operId, std::string operName, std::string parentOperId); + + /** + * Parses the metadata from the given metadata object. + * Returns a NoSuchKey error status if it does not have operId or operName set. + * Returns a TypeMismatch error if operId is not OID and operName or parentOperId are not String + * If no metadata is found, returns a default-constructed TrackingMetadata. + */ + static StatusWith<TrackingMetadata> readFromMetadata(const BSONObj& metadataObj); + + /** + * Parses TrackingMetadata from a pre-extracted BSONElement. When reading a metadata object, + * this form is more efficient as it permits parsing the metadata in one pass. + */ + static StatusWith<TrackingMetadata> readFromMetadata(const BSONElement& metadataElem); + + /** + * Writes the metadata to the given BSONObjBuilder for building a command request or response + * metadata. Only valid to call if operId and operName are set. + */ + void writeToMetadata(BSONObjBuilder* builder) const; + + /** + * Returns the Id of this operation. + */ + boost::optional<OID> getOperId() const { + return _operId; + } + + /** + * Returns the name of this operation. + */ + boost::optional<std::string> getOperName() const { + return _operName; + } + + /** + * Returns the parent operId of this operation. + */ + boost::optional<std::string> getParentOperId() const { + return _parentOperId; + } + + static StringData fieldName() { + return "tracking_info"; + } + + /** + * Sets operName to name argument. Intended to initialize the metadata when command name is + * known. + */ + void initWithOperName(const std::string& name); + + /* + * get|set isLogged are used to avoid logging parent metadata more than once. + */ + bool getIsLogged() const { + return _isLogged; + } + + void setIsLogged(bool isLogged) { + _isLogged = isLogged; + } + + /* + * Builds metadata for child command by updating parentOperId with current operId and + * setting operId to a new value. + */ + TrackingMetadata constructChildMetadata() const; + + std::string toString() const; + + static BSONObj removeTrackingData(BSONObj metadata); + +private: + boost::optional<OID> _operId; + boost::optional<std::string> _operName; + boost::optional<std::string> _parentOperId; + bool _isLogged{false}; +}; + +} // namespace rpc +} // namespace mongo diff --git a/src/mongo/rpc/metadata/tracking_metadata_test.cpp b/src/mongo/rpc/metadata/tracking_metadata_test.cpp new file mode 100644 index 00000000000..f2f43f6b138 --- /dev/null +++ b/src/mongo/rpc/metadata/tracking_metadata_test.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2016 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/base/status.h" +#include "mongo/db/jsobj.h" +#include "mongo/db/repl/optime.h" +#include "mongo/rpc/metadata/tracking_metadata.h" +#include "mongo/stdx/chrono.h" +#include "mongo/unittest/unittest.h" + +namespace { + +using namespace mongo; +using namespace mongo::rpc; +using mongo::unittest::assertGet; + +TrackingMetadata checkParse(const BSONObj& metadata) { + return assertGet(TrackingMetadata::readFromMetadata(metadata)); +} + +const auto kOperId = OID{"541b1a00e8a23afa832b218e"}; +const auto kOperName = "testCmd"; +const auto kParentOperId = "541b1a00e8a23afa832b2016"; + +TEST(TrackingMetadata, ReadFromMetadata) { + { + auto metadata = checkParse(BSON( + "tracking_info" << BSON("operId" << kOperId << "operName" << kOperName << "parentOperId" + << kParentOperId))); + ASSERT_EQ(*metadata.getOperId(), kOperId); + ASSERT_EQ(*metadata.getParentOperId(), kParentOperId); + ASSERT_EQ(*metadata.getOperName(), kOperName); + } +} + +void checkParseFails(const BSONObj& metadata, ErrorCodes::Error error) { + auto tm = TrackingMetadata::readFromMetadata(metadata); + ASSERT_NOT_OK(tm.getStatus()); + ASSERT_EQ(tm.getStatus(), error); +} + +TEST(TrackingMetadata, ReadFromInvalidMetadata) { + { checkParseFails(BSON("tracking_info" << 1), ErrorCodes::TypeMismatch); } + { checkParseFails(BSON("tracking_info" << BSON("o" << 111)), ErrorCodes::NoSuchKey); } + { checkParseFails(BSON("tracking_info" << BSON("operId" << 111)), ErrorCodes::TypeMismatch); } + { checkParseFails(BSON("tracking_info" << BSON("operId" << kOperId)), ErrorCodes::NoSuchKey); } + { + checkParseFails(BSON("tracking_info" << BSON("operId" << kOperId << "operName" << 111)), + ErrorCodes::TypeMismatch); + } + { + checkParseFails(BSON("tracking_info" << BSON("operId" << kOperId << "operName" << kOperName + << "parentOperId" + << 111)), + ErrorCodes::TypeMismatch); + } +} + +TEST(TrackingMetadata, Roundtrip1) { + BSONObjBuilder bob; + TrackingMetadata tmBefore{kOperId, kOperName, kParentOperId}; + tmBefore.writeToMetadata(&bob); + auto tmAfter = TrackingMetadata::readFromMetadata(bob.obj()); + ASSERT_OK(tmAfter.getStatus()); + auto metadata = tmAfter.getValue(); + ASSERT_EQ(*metadata.getOperId(), kOperId); + ASSERT_EQ(*metadata.getParentOperId(), kParentOperId); + ASSERT_EQ(*metadata.getOperName(), kOperName); +} + +TEST(TrackingMetadata, Roundtrip2) { + BSONObjBuilder bob; + TrackingMetadata tmBefore{kOperId, kOperName}; + tmBefore.writeToMetadata(&bob); + auto tmAfter = TrackingMetadata::readFromMetadata(bob.obj()); + ASSERT_OK(tmAfter.getStatus()); + auto metadata = tmAfter.getValue(); + ASSERT_EQ(*metadata.getOperId(), kOperId); + ASSERT_EQ(*metadata.getOperName(), kOperName); +} + +} // namespace diff --git a/src/mongo/s/balancer_configuration_test.cpp b/src/mongo/s/balancer_configuration_test.cpp index e889e4a5ded..72a3b8da06d 100644 --- a/src/mongo/s/balancer_configuration_test.cpp +++ b/src/mongo/s/balancer_configuration_test.cpp @@ -38,6 +38,7 @@ #include "mongo/executor/remote_command_request.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/balancer_configuration.h" #include "mongo/s/catalog/sharding_catalog_client.h" #include "mongo/s/sharding_test_fixture.h" @@ -66,7 +67,8 @@ protected: */ void expectSettingsQuery(StringData key, StatusWith<boost::optional<BSONObj>> result) { onFindCommand([&](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), "config.settings"); diff --git a/src/mongo/s/catalog/sharding_catalog_append_db_stats_test.cpp b/src/mongo/s/catalog/sharding_catalog_append_db_stats_test.cpp index 22b2d3ffbad..d3f46f56f63 100644 --- a/src/mongo/s/catalog/sharding_catalog_append_db_stats_test.cpp +++ b/src/mongo/s/catalog/sharding_catalog_append_db_stats_test.cpp @@ -35,6 +35,7 @@ #include "mongo/executor/network_interface_mock.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/catalog/sharding_catalog_client_impl.h" #include "mongo/s/catalog/sharding_catalog_test_fixture.h" #include "mongo/stdx/future.h" @@ -67,7 +68,8 @@ TEST_F(ShardingCatalogClientAppendDbStatsTest, BasicAppendDBStats) { }); onCommand([](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ("admin", request.dbname); ASSERT_BSONOBJ_EQ(BSON("listDatabases" << 1), request.cmdObj); diff --git a/src/mongo/s/catalog/sharding_catalog_drop_coll_test.cpp b/src/mongo/s/catalog/sharding_catalog_drop_coll_test.cpp index 4777550a370..3497dc6cfc9 100644 --- a/src/mongo/s/catalog/sharding_catalog_drop_coll_test.cpp +++ b/src/mongo/s/catalog/sharding_catalog_drop_coll_test.cpp @@ -35,6 +35,7 @@ #include "mongo/db/namespace_string.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/catalog/dist_lock_manager_mock.h" #include "mongo/s/catalog/sharding_catalog_client_impl.h" #include "mongo/s/catalog/sharding_catalog_test_fixture.h" @@ -97,7 +98,8 @@ public: << BSON("w" << 0 << "wtimeout" << 0)), request.cmdObj); - ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), request.metadata); + ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ns" << _dropNS.ns() << "ok" << 1); }); @@ -105,7 +107,8 @@ public: void expectRemoveChunksAndMarkCollectionDropped() { onCommand([this](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ(_configHost, request.target); ASSERT_EQ("config", request.dbname); @@ -141,7 +144,8 @@ public: ASSERT_EQ("admin", request.dbname); ASSERT_BSONOBJ_EQ(BSON("unsetSharding" << 1), request.cmdObj); - ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), request.metadata); + ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("n" << 1 << "ok" << 1); }); @@ -222,7 +226,8 @@ TEST_F(DropColl2ShardTest, NSNotFound) { BSON("drop" << dropNS().coll() << "writeConcern" << BSON("w" << 0 << "wtimeout" << 0)), request.cmdObj); - ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), request.metadata); + ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 0 << "code" << ErrorCodes::NamespaceNotFound); }); @@ -234,7 +239,8 @@ TEST_F(DropColl2ShardTest, NSNotFound) { BSON("drop" << dropNS().coll() << "writeConcern" << BSON("w" << 0 << "wtimeout" << 0)), request.cmdObj); - ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), request.metadata); + ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 0 << "code" << ErrorCodes::NamespaceNotFound); }); diff --git a/src/mongo/s/catalog/sharding_catalog_remove_shard_test.cpp b/src/mongo/s/catalog/sharding_catalog_remove_shard_test.cpp index 1e9acc10ed9..b9b8285ce33 100644 --- a/src/mongo/s/catalog/sharding_catalog_remove_shard_test.cpp +++ b/src/mongo/s/catalog/sharding_catalog_remove_shard_test.cpp @@ -39,6 +39,7 @@ #include "mongo/executor/task_executor.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/catalog/sharding_catalog_client_impl.h" #include "mongo/s/catalog/sharding_catalog_test_fixture.h" #include "mongo/s/catalog/type_chunk.h" @@ -155,7 +156,8 @@ TEST_F(RemoveShardTest, RemoveShardStartDraining) { ASSERT_EQUALS(configHost, request.target); ASSERT_EQUALS("config", request.dbname); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BatchedUpdateRequest actualBatchedUpdate; std::string errmsg; @@ -180,7 +182,8 @@ TEST_F(RemoveShardTest, RemoveShardStartDraining) { // Respond to request to reload information about existing shards onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); auto query = assertGet(QueryRequest::makeFromFindCommand(nss, request.cmdObj, false)); @@ -329,7 +332,8 @@ TEST_F(RemoveShardTest, RemoveShardCompletion) { ASSERT_EQUALS(configHost, request.target); ASSERT_EQUALS("config", request.dbname); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BatchedDeleteRequest actualBatchedDelete; std::string errmsg; @@ -352,7 +356,8 @@ TEST_F(RemoveShardTest, RemoveShardCompletion) { // Respond to request to reload information about existing shards onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); auto query = assertGet(QueryRequest::makeFromFindCommand(nss, request.cmdObj, false)); diff --git a/src/mongo/s/catalog/sharding_catalog_shard_collection_test.cpp b/src/mongo/s/catalog/sharding_catalog_shard_collection_test.cpp index ce2edb237fe..920714e4ad3 100644 --- a/src/mongo/s/catalog/sharding_catalog_shard_collection_test.cpp +++ b/src/mongo/s/catalog/sharding_catalog_shard_collection_test.cpp @@ -42,6 +42,7 @@ #include "mongo/executor/task_executor.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/catalog/dist_lock_manager_mock.h" #include "mongo/s/catalog/sharding_catalog_client_impl.h" #include "mongo/s/catalog/sharding_catalog_test_fixture.h" @@ -90,7 +91,8 @@ public: void expectGetDatabase(const DatabaseType& expectedDb) { onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(DatabaseType::ConfigNS, nss.ns()); @@ -118,7 +120,8 @@ public: ASSERT_EQUALS(configHost, request.target); ASSERT_EQUALS("config", request.dbname); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BatchedInsertRequest actualBatchedInsert; std::string errmsg; @@ -154,7 +157,8 @@ public: void expectReloadChunks(const std::string& ns, const vector<ChunkType>& chunks) { onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), ChunkType::ConfigNS); @@ -186,7 +190,8 @@ public: ASSERT_EQUALS(configHost, request.target); ASSERT_EQUALS("config", request.dbname); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BatchedUpdateRequest actualBatchedUpdate; std::string errmsg; @@ -755,7 +760,7 @@ TEST_F(ShardCollectionTest, withInitialData) { ASSERT_EQUALS(0, request.cmdObj["maxChunkObjects"].numberLong()); ASSERT_BSONOBJ_EQ(rpc::ServerSelectionMetadata(true, boost::none).toBSON(), - request.metadata); + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 1 << "splitKeys" << BSON_ARRAY(splitPoint0 << splitPoint1 << splitPoint2 << splitPoint3)); diff --git a/src/mongo/s/catalog/sharding_catalog_test.cpp b/src/mongo/s/catalog/sharding_catalog_test.cpp index 384b9239276..115bc3538c6 100644 --- a/src/mongo/s/catalog/sharding_catalog_test.cpp +++ b/src/mongo/s/catalog/sharding_catalog_test.cpp @@ -42,6 +42,7 @@ #include "mongo/rpc/get_status_from_command_result.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/catalog/dist_lock_manager_mock.h" #include "mongo/s/catalog/sharding_catalog_client_impl.h" #include "mongo/s/catalog/sharding_catalog_test_fixture.h" @@ -102,7 +103,8 @@ TEST_F(ShardingCatalogClientTest, GetCollectionExisting) { onFindWithMetadataCommand( [this, &expectedColl, newOpTime](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), CollectionType::ConfigNS); @@ -169,7 +171,8 @@ TEST_F(ShardingCatalogClientTest, GetDatabaseExisting) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), DatabaseType::ConfigNS); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); auto query = assertGet(QueryRequest::makeFromFindCommand(nss, request.cmdObj, false)); @@ -396,7 +399,8 @@ TEST_F(ShardingCatalogClientTest, GetAllShardsValid) { }); onFindCommand([this, &s1, &s2, &s3](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), ShardType::ConfigNS); @@ -493,7 +497,8 @@ TEST_F(ShardingCatalogClientTest, GetChunksForNSWithSortAndLimit) { onFindWithMetadataCommand([this, &chunksQuery, chunkA, chunkB, newOpTime]( const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), ChunkType::ConfigNS); @@ -545,7 +550,8 @@ TEST_F(ShardingCatalogClientTest, GetChunksForNSNoSortNoLimit) { }); onFindCommand([this, &chunksQuery](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), ChunkType::ConfigNS); @@ -626,7 +632,8 @@ TEST_F(ShardingCatalogClientTest, RunUserManagementReadCommand) { }); onCommand([](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQUALS("test", request.dbname); ASSERT_BSONOBJ_EQ(BSON("usersInfo" << 1 << "maxTimeMS" << 30000), request.cmdObj); @@ -681,7 +688,8 @@ TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandSuccess) { << 30000), request.cmdObj); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BSONObjBuilder responseBuilder; Command::appendCommandStatus(responseBuilder, @@ -753,7 +761,8 @@ TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandRewriteWriteConce << 30000), request.cmdObj); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BSONObjBuilder responseBuilder; Command::appendCommandStatus(responseBuilder, @@ -842,7 +851,8 @@ TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandNotMasterRetrySuc << 30000), request.cmdObj); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 1); }); @@ -895,7 +905,8 @@ TEST_F(ShardingCatalogClientTest, GetCollectionsValidResultsNoDb) { onFindWithMetadataCommand( [this, coll1, coll2, coll3, newOpTime](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), CollectionType::ConfigNS); @@ -952,7 +963,8 @@ TEST_F(ShardingCatalogClientTest, GetCollectionsValidResultsWithDb) { }); onFindCommand([this, coll1, coll2](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), CollectionType::ConfigNS); @@ -1003,7 +1015,8 @@ TEST_F(ShardingCatalogClientTest, GetCollectionsInvalidCollectionType) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), CollectionType::ConfigNS); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); auto query = assertGet(QueryRequest::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1046,7 +1059,8 @@ TEST_F(ShardingCatalogClientTest, GetDatabasesForShardValid) { }); onFindCommand([this, dbt1, dbt2](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), DatabaseType::ConfigNS); @@ -1121,7 +1135,8 @@ TEST_F(ShardingCatalogClientTest, GetTagsForCollection) { }); onFindCommand([this, tagA, tagB](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), TagsType::ConfigNS); @@ -1207,7 +1222,8 @@ TEST_F(ShardingCatalogClientTest, GetTagForChunkOneTagFound) { }); onFindCommand([this, chunk](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), TagsType::ConfigNS); @@ -1252,7 +1268,8 @@ TEST_F(ShardingCatalogClientTest, GetTagForChunkNoTagFound) { }); onFindCommand([this, chunk](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), TagsType::ConfigNS); @@ -1294,7 +1311,8 @@ TEST_F(ShardingCatalogClientTest, GetTagForChunkInvalidTagDoc) { }); onFindCommand([this, chunk](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), TagsType::ConfigNS); @@ -1334,7 +1352,8 @@ TEST_F(ShardingCatalogClientTest, UpdateDatabase) { onCommand([dbt](const RemoteCommandRequest& request) { ASSERT_EQUALS("config", request.dbname); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BatchedUpdateRequest actualBatchedUpdate; std::string errmsg; @@ -1422,7 +1441,8 @@ TEST_F(ShardingCatalogClientTest, ApplyChunkOpsDeprecatedSuccessful) { << "wtimeout" << 15000), request.cmdObj["writeConcern"].Obj()); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_BSONOBJ_EQ(updateOps, request.cmdObj["applyOps"].Obj()); ASSERT_BSONOBJ_EQ(preCondition, request.cmdObj["preCondition"].Obj()); @@ -1542,7 +1562,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseSuccess) { onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); auto query = assertGet(QueryRequest::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1585,7 +1606,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseSuccess) { onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ(DatabaseType::ConfigNS, nss.ns()); checkReadConcern(request.cmdObj, Timestamp(0, 0), repl::OpTime::kUninitializedTerm); return vector<BSONObj>{}; @@ -1600,7 +1622,7 @@ TEST_F(ShardingCatalogClientTest, createDatabaseSuccess) { ASSERT_FALSE(request.cmdObj.hasField(repl::ReadConcernArgs::kReadConcernFieldName)); ASSERT_BSONOBJ_EQ(rpc::ServerSelectionMetadata(true, boost::none).toBSON(), - request.metadata); + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 1 << "totalSize" << 10); }); @@ -1614,7 +1636,7 @@ TEST_F(ShardingCatalogClientTest, createDatabaseSuccess) { ASSERT_FALSE(request.cmdObj.hasField(repl::ReadConcernArgs::kReadConcernFieldName)); ASSERT_BSONOBJ_EQ(rpc::ServerSelectionMetadata(true, boost::none).toBSON(), - request.metadata); + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 1 << "totalSize" << 1); }); @@ -1627,7 +1649,7 @@ TEST_F(ShardingCatalogClientTest, createDatabaseSuccess) { ASSERT_EQUALS("listDatabases", cmdName); ASSERT_BSONOBJ_EQ(rpc::ServerSelectionMetadata(true, boost::none).toBSON(), - request.metadata); + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 1 << "totalSize" << 100); }); @@ -1637,7 +1659,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseSuccess) { ASSERT_EQUALS(configHost, request.target); ASSERT_EQUALS("config", request.dbname); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BatchedInsertRequest actualBatchedInsert; std::string errmsg; @@ -1698,7 +1721,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseDBExists) { }); onFindCommand([this, dbname](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); auto query = assertGet(QueryRequest::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1734,7 +1758,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseDBExistsDifferentCase) { }); onFindCommand([this, dbname, dbnameDiffCase](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); auto query = assertGet(QueryRequest::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1770,7 +1795,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseNoShards) { // Report no databases with the same name already exist onFindCommand([this, dbname](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(DatabaseType::ConfigNS, nss.ns()); checkReadConcern(request.cmdObj, Timestamp(0, 0), repl::OpTime::kUninitializedTerm); @@ -1779,7 +1805,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseNoShards) { // Report no shards exist onFindCommand([this](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); auto query = assertGet(QueryRequest::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1818,7 +1845,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseDuplicateKeyOnInsert) { onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); auto query = assertGet(QueryRequest::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1859,7 +1887,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseDuplicateKeyOnInsert) { // Report no databases with the same name already exist onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(DatabaseType::ConfigNS, nss.ns()); checkReadConcern(request.cmdObj, Timestamp(0, 0), repl::OpTime::kUninitializedTerm); @@ -1875,7 +1904,7 @@ TEST_F(ShardingCatalogClientTest, createDatabaseDuplicateKeyOnInsert) { ASSERT_FALSE(request.cmdObj.hasField(repl::ReadConcernArgs::kReadConcernFieldName)); ASSERT_BSONOBJ_EQ(rpc::ServerSelectionMetadata(true, boost::none).toBSON(), - request.metadata); + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 1 << "totalSize" << 10); }); @@ -1889,7 +1918,7 @@ TEST_F(ShardingCatalogClientTest, createDatabaseDuplicateKeyOnInsert) { ASSERT_FALSE(request.cmdObj.hasField(repl::ReadConcernArgs::kReadConcernFieldName)); ASSERT_BSONOBJ_EQ(rpc::ServerSelectionMetadata(true, boost::none).toBSON(), - request.metadata); + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 1 << "totalSize" << 1); }); @@ -1903,7 +1932,7 @@ TEST_F(ShardingCatalogClientTest, createDatabaseDuplicateKeyOnInsert) { ASSERT_FALSE(request.cmdObj.hasField(repl::ReadConcernArgs::kReadConcernFieldName)); ASSERT_BSONOBJ_EQ(rpc::ServerSelectionMetadata(true, boost::none).toBSON(), - request.metadata); + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return BSON("ok" << 1 << "totalSize" << 100); }); @@ -1914,7 +1943,8 @@ TEST_F(ShardingCatalogClientTest, createDatabaseDuplicateKeyOnInsert) { ASSERT_EQUALS("config", request.dbname); ASSERT_FALSE(request.cmdObj.hasField(repl::ReadConcernArgs::kReadConcernFieldName)); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BatchedInsertRequest actualBatchedInsert; std::string errmsg; @@ -1972,7 +2002,8 @@ TEST_F(ShardingCatalogClientTest, EnableShardingNoDBExists) { // Query to find if db already exists in config. onFindCommand([this](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(DatabaseType::ConfigNS, nss.toString()); @@ -1999,7 +2030,7 @@ TEST_F(ShardingCatalogClientTest, EnableShardingNoDBExists) { ASSERT_BSONOBJ_EQ(BSON("listDatabases" << 1), request.cmdObj); ASSERT_BSONOBJ_EQ(rpc::ServerSelectionMetadata(true, boost::none).toBSON(), - request.metadata); + rpc::TrackingMetadata::removeTrackingData(request.metadata)); return fromjson(R"({ databases: [], @@ -2012,7 +2043,8 @@ TEST_F(ShardingCatalogClientTest, EnableShardingNoDBExists) { ASSERT_EQ(HostAndPort("config:123"), request.target); ASSERT_EQ("config", request.dbname); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BSONObj expectedCmd(fromjson(R"({ update: "databases", @@ -2105,7 +2137,8 @@ TEST_F(ShardingCatalogClientTest, EnableShardingDBExists) { ASSERT_EQ(HostAndPort("config:123"), request.target); ASSERT_EQ("config", request.dbname); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); BSONObj expectedCmd(fromjson(R"({ update: "databases", @@ -2223,7 +2256,8 @@ TEST_F(ShardingCatalogClientTest, BasicReadAfterOpTime) { onCommandWithMetadata([this, &newOpTime, &lastOpTime](const RemoteCommandRequest& request) { ASSERT_EQUALS("test", request.dbname); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ(string("dummy"), request.cmdObj.firstElementFieldName()); checkReadConcern(request.cmdObj, lastOpTime.getTimestamp(), lastOpTime.getTerm()); @@ -2258,7 +2292,8 @@ TEST_F(ShardingCatalogClientTest, ReadAfterOpTimeShouldNotGoBack) { onCommandWithMetadata([this, &newOpTime, &highestOpTime](const RemoteCommandRequest& request) { ASSERT_EQUALS("test", request.dbname); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ(string("dummy"), request.cmdObj.firstElementFieldName()); checkReadConcern(request.cmdObj, highestOpTime.getTimestamp(), highestOpTime.getTerm()); @@ -2286,7 +2321,8 @@ TEST_F(ShardingCatalogClientTest, ReadAfterOpTimeShouldNotGoBack) { onCommandWithMetadata([this, &oldOpTime, &highestOpTime](const RemoteCommandRequest& request) { ASSERT_EQUALS("test", request.dbname); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ(string("dummy"), request.cmdObj.firstElementFieldName()); checkReadConcern(request.cmdObj, highestOpTime.getTimestamp(), highestOpTime.getTerm()); @@ -2310,7 +2346,8 @@ TEST_F(ShardingCatalogClientTest, ReadAfterOpTimeShouldNotGoBack) { onCommandWithMetadata([this, &oldOpTime, &highestOpTime](const RemoteCommandRequest& request) { ASSERT_EQUALS("test", request.dbname); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ(string("dummy"), request.cmdObj.firstElementFieldName()); checkReadConcern(request.cmdObj, highestOpTime.getTimestamp(), highestOpTime.getTerm()); @@ -2337,7 +2374,8 @@ TEST_F(ShardingCatalogClientTest, ReadAfterOpTimeFindThenCmd) { onFindWithMetadataCommand( [this, &newOpTime, &highestOpTime](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); checkReadConcern(request.cmdObj, highestOpTime.getTimestamp(), highestOpTime.getTerm()); ReplSetMetadata metadata(10, newOpTime, newOpTime, 100, OID(), 30, -1); @@ -2368,7 +2406,8 @@ TEST_F(ShardingCatalogClientTest, ReadAfterOpTimeFindThenCmd) { onCommand([this, &oldOpTime, &highestOpTime](const RemoteCommandRequest& request) { ASSERT_EQUALS("test", request.dbname); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ(string("dummy"), request.cmdObj.firstElementFieldName()); checkReadConcern(request.cmdObj, highestOpTime.getTimestamp(), highestOpTime.getTerm()); @@ -2395,7 +2434,8 @@ TEST_F(ShardingCatalogClientTest, ReadAfterOpTimeCmdThenFind) { onCommandWithMetadata([this, &newOpTime, &highestOpTime](const RemoteCommandRequest& request) { ASSERT_EQUALS("test", request.dbname); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ(string("dummy"), request.cmdObj.firstElementFieldName()); checkReadConcern(request.cmdObj, highestOpTime.getTimestamp(), highestOpTime.getTerm()); @@ -2419,7 +2459,8 @@ TEST_F(ShardingCatalogClientTest, ReadAfterOpTimeCmdThenFind) { const OpTime oldOpTime(Timestamp(3, 10), 5); onFindCommand([this, &oldOpTime, &highestOpTime](const RemoteCommandRequest& request) { - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQ(string("find"), request.cmdObj.firstElementFieldName()); checkReadConcern(request.cmdObj, highestOpTime.getTimestamp(), highestOpTime.getTerm()); diff --git a/src/mongo/s/client/shard_remote.cpp b/src/mongo/s/client/shard_remote.cpp index 200f3fc30ad..997c32c2387 100644 --- a/src/mongo/s/client/shard_remote.cpp +++ b/src/mongo/s/client/shard_remote.cpp @@ -48,6 +48,7 @@ #include "mongo/rpc/get_status_from_command_result.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/grid.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" @@ -60,12 +61,10 @@ using std::string; using executor::RemoteCommandRequest; using executor::RemoteCommandResponse; using executor::TaskExecutor; +using rpc::TrackingMetadata; using RemoteCommandCallbackArgs = TaskExecutor::RemoteCommandCallbackArgs; namespace { - -const BSONObj kNoMetadata(rpc::makeEmptyMetadata()); - // Include kReplSetMetadataFieldName in a request to get the shard's ReplSetMetadata in the // response. const BSONObj kReplMetadata(BSON(rpc::kReplSetMetadataFieldName << 1)); @@ -73,15 +72,6 @@ const BSONObj kReplMetadata(BSON(rpc::kReplSetMetadataFieldName << 1)); // Allow the command to be executed on a secondary (see ServerSelectionMetadata). const BSONObj kSecondaryOkMetadata{rpc::ServerSelectionMetadata(true, boost::none).toBSON()}; -// Helper for requesting ReplSetMetadata in the response as well as allowing the command to be -// executed on a secondary. -const BSONObj kReplSecondaryOkMetadata{[] { - BSONObjBuilder o; - o.appendElements(kSecondaryOkMetadata); - o.appendElements(kReplMetadata); - return o.obj(); -}()}; - /** * Returns a new BSONObj describing the same command and arguments as 'cmdObj', but with maxTimeMS * replaced by maxTimeMSOverride (or removed if maxTimeMSOverride is Milliseconds::max()). @@ -150,20 +140,38 @@ std::string ShardRemote::toString() const { return getId().toString() + ":" + _originalConnString.toString(); } -const BSONObj& ShardRemote::_getMetadataForCommand(const ReadPreferenceSetting& readPref) { +BSONObj ShardRemote::_appendMetadataForCommand(OperationContext* txn, + const ReadPreferenceSetting& readPref) { + BSONObjBuilder builder; + if (logger::globalLogDomain()->shouldLog( + logger::LogComponent::kTracking, + logger::LogSeverity::Debug(1))) { // avoid performance overhead if not logging + if (!TrackingMetadata::get(txn).getIsLogged()) { + if (!TrackingMetadata::get(txn).getOperId()) { + TrackingMetadata::get(txn).initWithOperName("NotSet"); + } + MONGO_LOG_COMPONENT(1, logger::LogComponent::kTracking) + << TrackingMetadata::get(txn).toString(); + TrackingMetadata::get(txn).setIsLogged(true); + } + + TrackingMetadata metadata = TrackingMetadata::get(txn).constructChildMetadata(); + metadata.writeToMetadata(&builder); + } + if (isConfig()) { if (readPref.pref == ReadPreference::PrimaryOnly) { - return kReplMetadata; + builder.appendElements(kReplMetadata); } else { - return kReplSecondaryOkMetadata; + builder.appendElements(kSecondaryOkMetadata); + builder.appendElements(kReplMetadata); } } else { - if (readPref.pref == ReadPreference::PrimaryOnly) { - return kNoMetadata; - } else { - return kSecondaryOkMetadata; + if (readPref.pref != ReadPreference::PrimaryOnly) { + builder.appendElements(kSecondaryOkMetadata); } } + return builder.obj(); } Shard::HostWithResponse ShardRemote::_runCommand(OperationContext* txn, @@ -188,7 +196,7 @@ Shard::HostWithResponse ShardRemote::_runCommand(OperationContext* txn, host.getValue(), dbName, appendMaxTimeToCmdObj(maxTimeMSOverride, cmdObj), - _getMetadataForCommand(readPrefWithMinOpTime), + _appendMetadataForCommand(txn, readPrefWithMinOpTime), txn, requestTimeout < Milliseconds::max() ? requestTimeout : RemoteCommandRequest::kNoTimeout); @@ -330,7 +338,7 @@ StatusWith<Shard::QueryResponse> ShardRemote::_exhaustiveFindOnConfig( nss.db().toString(), findCmdBuilder.done(), fetcherCallback, - _getMetadataForCommand(readPrefWithMinOpTime), + _appendMetadataForCommand(txn, readPrefWithMinOpTime), maxTimeMS); Status scheduleStatus = fetcher.schedule(); if (!scheduleStatus.isOK()) { diff --git a/src/mongo/s/client/shard_remote.h b/src/mongo/s/client/shard_remote.h index 9615cd0e4fa..908ebf33eee 100644 --- a/src/mongo/s/client/shard_remote.h +++ b/src/mongo/s/client/shard_remote.h @@ -79,11 +79,8 @@ private: /** * Returns the metadata that should be used when running commands against this shard with * the given read preference. - * - * NOTE: This method returns a reference to a constant defined in shard_remote.cpp. Be careful - * to never change it to return a reference to a temporary. */ - const BSONObj& _getMetadataForCommand(const ReadPreferenceSetting& readPref); + BSONObj _appendMetadataForCommand(OperationContext* txn, const ReadPreferenceSetting& readPref); Shard::HostWithResponse _runCommand(OperationContext* txn, const ReadPreferenceSetting& readPref, diff --git a/src/mongo/s/cluster_identity_loader_test.cpp b/src/mongo/s/cluster_identity_loader_test.cpp index f7e33f58b51..fd9c0f474e2 100644 --- a/src/mongo/s/cluster_identity_loader_test.cpp +++ b/src/mongo/s/cluster_identity_loader_test.cpp @@ -39,6 +39,7 @@ #include "mongo/executor/task_executor.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/catalog/config_server_version.h" #include "mongo/s/catalog/sharding_catalog_client_impl.h" #include "mongo/s/catalog/type_config_version.h" @@ -76,7 +77,8 @@ public: void expectConfigVersionLoad(StatusWith<OID> result) { onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); - ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, request.metadata); + ASSERT_BSONOBJ_EQ(kReplSecondaryOkMetadata, + rpc::TrackingMetadata::removeTrackingData(request.metadata)); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); ASSERT_EQ(nss.ns(), "config.version"); diff --git a/src/mongo/s/s_only.cpp b/src/mongo/s/s_only.cpp index ca5d63625f2..2fcfc4c30b2 100644 --- a/src/mongo/s/s_only.cpp +++ b/src/mongo/s/s_only.cpp @@ -42,6 +42,7 @@ #include "mongo/db/stats/counters.h" #include "mongo/db/write_concern_options.h" #include "mongo/rpc/metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/rpc/reply_builder_interface.h" #include "mongo/rpc/request_interface.h" #include "mongo/s/cluster_last_error_info.h" @@ -134,6 +135,11 @@ void Command::execCommandClient(OperationContext* txn, } + // attach tracking + rpc::TrackingMetadata trackingMetadata; + trackingMetadata.initWithOperName(c->getName()); + rpc::TrackingMetadata::get(txn) = trackingMetadata; + std::string errmsg; bool ok = false; try { diff --git a/src/mongo/s/sharding_test_fixture.cpp b/src/mongo/s/sharding_test_fixture.cpp index 0f927c81614..41c8936f49c 100644 --- a/src/mongo/s/sharding_test_fixture.cpp +++ b/src/mongo/s/sharding_test_fixture.cpp @@ -49,6 +49,7 @@ #include "mongo/executor/thread_pool_task_executor_test_fixture.h" #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/metadata/server_selection_metadata.h" +#include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/balancer_configuration.h" #include "mongo/s/catalog/catalog_cache.h" #include "mongo/s/catalog/dist_lock_manager_mock.h" @@ -413,7 +414,8 @@ void ShardingTestFixture::expectUpdateCollection(const HostAndPort& expectedHost const CollectionType& coll) { onCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(expectedHost, request.target); - ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), request.metadata); + ASSERT_BSONOBJ_EQ(BSON(rpc::kReplSetMetadataFieldName << 1), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); ASSERT_EQUALS("config", request.dbname); BatchedUpdateRequest actualBatchedUpdate; @@ -444,7 +446,8 @@ void ShardingTestFixture::expectSetShardVersion(const HostAndPort& expectedHost, const ChunkVersion& expectedChunkVersion) { onCommand([&](const RemoteCommandRequest& request) { ASSERT_EQ(expectedHost, request.target); - ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), request.metadata); + ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), + rpc::TrackingMetadata::removeTrackingData(request.metadata)); SetShardVersionRequest ssv = assertGet(SetShardVersionRequest::parseFromBSON(request.cmdObj)); diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js index 5625ae44a80..d897bf7e5df 100644 --- a/src/mongo/shell/servers.js +++ b/src/mongo/shell/servers.js @@ -965,6 +965,10 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro if (baseProgramName === 'mongod' || baseProgramName === 'mongos') { if (jsTest.options().enableTestCommands) { argArray.push(...['--setParameter', "enableTestCommands=1"]); + if (!programVersion || (parseInt(programVersion.split(".")[0]) >= 3 && + parseInt(programVersion.split(".")[1]) >= 3)) { + argArray.push(...['--setParameter', "logComponentVerbosity={tracking:1}"]); + } } if (jsTest.options().authMechanism && jsTest.options().authMechanism != "SCRAM-SHA-1") { var hasAuthMechs = false; |