diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2021-03-11 14:09:32 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-17 15:09:46 +0000 |
commit | 2250938b17331942db77d40dbae2e25c23e57c2c (patch) | |
tree | 8305cc0ff6b1b99a22dca750cdbc0930a937ce09 /src/mongo/db/s/config | |
parent | 191e5b8f0c1b946e0ee785c908da82a14270fa22 (diff) | |
download | mongo-2250938b17331942db77d40dbae2e25c23e57c2c.tar.gz |
SERVER-52778 Cleanup the legacy shardCollection code path
Diffstat (limited to 'src/mongo/db/s/config')
-rw-r--r-- | src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp index 53ccc365113..d8f90700952 100644 --- a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp +++ b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp @@ -113,11 +113,11 @@ public: << "refineCollectionShardKey namespace " << nss << " is not sharded"); } - const auto oldShardKeyPattern = ShardKeyPattern(collType.getKeyPattern()); - const auto proposedKey = request().getKey().getOwned(); + const ShardKeyPattern oldShardKeyPattern(collType.getKeyPattern()); + const ShardKeyPattern newShardKeyPattern(request().getKey()); if (SimpleBSONObjComparator::kInstance.evaluate(oldShardKeyPattern.toBSON() == - proposedKey)) { + newShardKeyPattern.toBSON())) { repl::ReplClientInfo::forClient(opCtx->getClient()) .setLastOpToSystemLastOpTime(opCtx); return; @@ -131,12 +131,11 @@ public: // Validate the given shard key (i) extends the current shard key, (ii) has a "useful" // index, and (iii) the index in question has no null entries. - const auto newShardKeyPattern = ShardKeyPattern(proposedKey); - uassert(ErrorCodes::InvalidOptions, - str::stream() << "refineCollectionShardKey shard key " << proposedKey.toString() + str::stream() << "refineCollectionShardKey shard key " + << newShardKeyPattern.toString() << " does not extend the current shard key " - << collType.getKeyPattern().toString(), + << oldShardKeyPattern.toString(), oldShardKeyPattern.isExtendedBy(newShardKeyPattern)); // Indexes are loaded using shard versions, so validating the shard key may need to be @@ -152,7 +151,6 @@ public: shardkeyutil::validateShardKeyIndexExistsOrCreateIfPossible( opCtx, nss, - proposedKey, newShardKeyPattern, boost::none, collType.getUnique(), @@ -164,7 +162,8 @@ public: "CMD: refineCollectionShardKey", "request"_attr = request().toBSON({})); - audit::logRefineCollectionShardKey(opCtx->getClient(), nss.ns(), proposedKey); + audit::logRefineCollectionShardKey( + opCtx->getClient(), nss.ns(), newShardKeyPattern.toBSON()); ShardingCatalogManager::get(opCtx)->refineCollectionShardKey( opCtx, nss, newShardKeyPattern); |