diff options
author | Mihai Andrei <mihai.andrei@mongodb.com> | 2020-01-09 18:08:44 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-01-09 18:08:44 +0000 |
commit | 944e382e9b1cc6b873efaaa5aaf4c01a992f130f (patch) | |
tree | b2056fcf553bd44f92435fa0bea4a04c6d3e4052 /src | |
parent | 239faf80a16019dd5f5a84df0c858ce8937a9a91 (diff) | |
download | mongo-944e382e9b1cc6b873efaaa5aaf4c01a992f130f.tar.gz |
SERVER-44252 Delete implicit collection creation loop through the config server in sharding
Diffstat (limited to 'src')
12 files changed, 19 insertions, 25 deletions
diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp index 033ac978c46..e305217ed2d 100644 --- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp +++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp @@ -191,7 +191,7 @@ BSONObj genericTransformForShards(MutableDocument&& cmdForShards, cmdForShards[AggregationRequest::kUseNewUpsert] = Value(true); } - return appendAllowImplicitCreate(cmdForShards.freeze().toBson(), false); + return cmdForShards.freeze().toBson(); } std::vector<RemoteCursor> establishShardCursors( @@ -507,7 +507,7 @@ BSONObj createCommandForMergingShard(Document serializedCommand, mergeCmd.remove("readConcern"); } - return appendAllowImplicitCreate(mergeCmd.freeze().toBson(), false); + return mergeCmd.freeze().toBson(); } BSONObj createPassthroughCommandForShard( diff --git a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp index db2853bd8ea..c061abbc813 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp @@ -357,8 +357,7 @@ TEST_F(AddShardTest, CreateShardIdentityUpsertForAddShard) { << "writeConcern" << BSON("w" << "majority" - << "wtimeout" << 60000) - << "allowImplicitCollectionCreation" << false); + << "wtimeout" << 60000)); auto addShardCmd = add_shard_util::createAddShardCmd(operationContext(), shardName); auto actualBSON = add_shard_util::createShardIdentityUpsertForAddShard(addShardCmd); ASSERT_BSONOBJ_EQ(expectedBSON, actualBSON); diff --git a/src/mongo/db/s/scoped_operation_completion_sharding_actions.cpp b/src/mongo/db/s/scoped_operation_completion_sharding_actions.cpp index a8cdedf1e2b..5a8d900a810 100644 --- a/src/mongo/db/s/scoped_operation_completion_sharding_actions.cpp +++ b/src/mongo/db/s/scoped_operation_completion_sharding_actions.cpp @@ -101,7 +101,9 @@ ScopedOperationCompletionShardingActions::~ScopedOperationCompletionShardingActi << causedBy(redact(handleMismatchStatus)); } else if (auto cannotImplicitCreateCollInfo = status->extraInfo<CannotImplicitlyCreateCollectionInfo>()) { - if (ShardingState::get(_opCtx)->enabled()) { + if (ShardingState::get(_opCtx)->enabled() && + serverGlobalParams.featureCompatibility.getVersion() == + ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42) { auto handleCannotImplicitCreateStatus = onCannotImplicitlyCreateCollection(_opCtx, cannotImplicitCreateCollInfo->getNss()); if (!handleCannotImplicitCreateStatus.isOK()) diff --git a/src/mongo/db/s/shard_key_util.cpp b/src/mongo/db/s/shard_key_util.cpp index 0db51f2ded4..906757d353c 100644 --- a/src/mongo/db/s/shard_key_util.cpp +++ b/src/mongo/db/s/shard_key_util.cpp @@ -84,7 +84,7 @@ BSONObj makeCreateIndexesCmd(const NamespaceString& nss, createIndexes.append("createIndexes", nss.coll()); createIndexes.append("indexes", BSON_ARRAY(index.obj())); createIndexes.append("writeConcern", WriteConcernOptions::Majority); - return appendAllowImplicitCreate(createIndexes.obj(), false); + return createIndexes.obj(); } void validateShardKeyAgainstExistingIndexes(OperationContext* opCtx, diff --git a/src/mongo/db/s/shardsvr_shard_collection.cpp b/src/mongo/db/s/shardsvr_shard_collection.cpp index bf04f45e473..bf03a452569 100644 --- a/src/mongo/db/s/shardsvr_shard_collection.cpp +++ b/src/mongo/db/s/shardsvr_shard_collection.cpp @@ -185,7 +185,7 @@ BSONObj makeCreateIndexesCmd(const NamespaceString& nss, createIndexes.append("createIndexes", nss.coll()); createIndexes.append("indexes", BSON_ARRAY(index.obj())); createIndexes.append("writeConcern", WriteConcernOptions::Majority); - return appendAllowImplicitCreate(createIndexes.obj(), true); + return createIndexes.obj(); } /** diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp index 1f3021914d1..f365c4d4987 100644 --- a/src/mongo/db/service_entry_point_mongod.cpp +++ b/src/mongo/db/service_entry_point_mongod.cpp @@ -210,7 +210,9 @@ public: } } else if (auto cannotImplicitCreateCollInfo = e.extraInfo<CannotImplicitlyCreateCollectionInfo>()) { - if (ShardingState::get(opCtx)->enabled()) { + if (ShardingState::get(opCtx)->enabled() && + serverGlobalParams.featureCompatibility.getVersion() == + ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo42) { onCannotImplicitlyCreateCollection(opCtx, cannotImplicitCreateCollInfo->getNss()) .ignore(); } diff --git a/src/mongo/s/cluster_commands_helpers.cpp b/src/mongo/s/cluster_commands_helpers.cpp index 4921558463a..8e8daa948de 100644 --- a/src/mongo/s/cluster_commands_helpers.cpp +++ b/src/mongo/s/cluster_commands_helpers.cpp @@ -111,9 +111,6 @@ const auto kAllowImplicitCollectionCreation = "allowImplicitCollectionCreation"_ std::vector<AsyncRequestsSender::Request> buildUnversionedRequestsForShards( OperationContext* opCtx, std::vector<ShardId> shardIds, const BSONObj& cmdObj) { auto cmdToSend = cmdObj; - if (!cmdToSend.hasField(kAllowImplicitCollectionCreation)) { - cmdToSend = appendAllowImplicitCreate(cmdToSend, false); - } std::vector<AsyncRequestsSender::Request> requests; for (auto&& shardId : shardIds) @@ -138,9 +135,6 @@ std::vector<AsyncRequestsSender::Request> buildVersionedRequestsForTargetedShard const BSONObj& collation) { auto cmdToSend = cmdObj; - if (!cmdToSend.hasField(kAllowImplicitCollectionCreation)) { - cmdToSend = appendAllowImplicitCreate(cmdToSend, false); - } if (!routingInfo.cm()) { // The collection is unsharded. Target only the primary shard for the database. diff --git a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp index a7c60a5228a..b064f8057e9 100644 --- a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp +++ b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp @@ -286,8 +286,7 @@ private: bool isRetryableWrite = opCtx->getTxnNumber() && !TransactionRouter::get(opCtx); const auto response = [&] { std::vector<AsyncRequestsSender::Request> requests; - BSONObj filteredCmdObj = appendAllowImplicitCreate( - CommandHelpers::filterCommandRequestForPassthrough(cmdObj), false); + BSONObj filteredCmdObj = CommandHelpers::filterCommandRequestForPassthrough(cmdObj); BSONObj cmdObjWithVersions(std::move(filteredCmdObj)); if (dbVersion) { cmdObjWithVersions = appendDbVersionIfPresent(cmdObjWithVersions, *dbVersion); diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp index 899e5cd7a63..b4abd3a4cba 100644 --- a/src/mongo/s/commands/commands_public.cpp +++ b/src/mongo/s/commands/commands_public.cpp @@ -290,10 +290,8 @@ public: NamespaceString::kAdminDb, fromNss, fromRoutingInfo, - appendAllowImplicitCreate( - applyReadWriteConcern( - opCtx, this, CommandHelpers::filterCommandRequestForPassthrough(cmdObj)), - true), + applyReadWriteConcern( + opCtx, this, CommandHelpers::filterCommandRequestForPassthrough(cmdObj)), Shard::RetryPolicy::kNoRetry, &result); } diff --git a/src/mongo/s/write_ops/batched_command_request.cpp b/src/mongo/s/write_ops/batched_command_request.cpp index ff719d81f07..92d4cebb9a2 100644 --- a/src/mongo/s/write_ops/batched_command_request.cpp +++ b/src/mongo/s/write_ops/batched_command_request.cpp @@ -134,7 +134,9 @@ void BatchedCommandRequest::serialize(BSONObjBuilder* builder) const { builder->append(kWriteConcern, *_writeConcern); } - builder->append(kAllowImplicitCollectionCreation, _allowImplicitCollectionCreation); + if (!_allowImplicitCollectionCreation) { + builder->append(kAllowImplicitCollectionCreation, _allowImplicitCollectionCreation); + } } BSONObj BatchedCommandRequest::toBSON() const { diff --git a/src/mongo/s/write_ops/batched_command_request.h b/src/mongo/s/write_ops/batched_command_request.h index 540f2c5f34d..8ce25b4025d 100644 --- a/src/mongo/s/write_ops/batched_command_request.h +++ b/src/mongo/s/write_ops/batched_command_request.h @@ -200,7 +200,7 @@ private: boost::optional<DatabaseVersion> _dbVersion; boost::optional<BSONObj> _writeConcern; - bool _allowImplicitCollectionCreation = false; + bool _allowImplicitCollectionCreation = true; }; /** diff --git a/src/mongo/s/write_ops/batched_command_request_test.cpp b/src/mongo/s/write_ops/batched_command_request_test.cpp index 603cbff2ba2..b438cc2842f 100644 --- a/src/mongo/s/write_ops/batched_command_request_test.cpp +++ b/src/mongo/s/write_ops/batched_command_request_test.cpp @@ -45,8 +45,7 @@ TEST(BatchedCommandRequest, BasicInsert) { BSONObj origInsertRequestObj = BSON("insert" << "test" << "documents" << insertArray << "writeConcern" - << BSON("w" << 1) << "ordered" << true - << "allowImplicitCollectionCreation" << false); + << BSON("w" << 1) << "ordered" << true); for (auto docSeq : {false, true}) { const auto opMsgRequest(toOpMsg("TestDB", origInsertRequestObj, docSeq)); @@ -54,7 +53,6 @@ TEST(BatchedCommandRequest, BasicInsert) { ASSERT_EQ("TestDB.test", insertRequest.getInsertRequest().getNamespace().ns()); ASSERT(!insertRequest.hasShardVersion()); - ASSERT_FALSE(insertRequest.isImplicitCreateAllowed()); } } |