summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/shard_collection_legacy.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2021-03-11 06:39:06 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-17 18:59:18 +0000
commite3b9f422e0977417f97821e53e436b3692d6037f (patch)
treef638ff90af4c91270d7d07be7d71a086798711ca /src/mongo/db/s/shard_collection_legacy.cpp
parent0afd76f0c80b7e33de15fd2bce7e409dd88318bc (diff)
downloadmongo-e3b9f422e0977417f97821e53e436b3692d6037f.tar.gz
SERVER-52778 Mark all places where collections are implicitly created in sharding
Diffstat (limited to 'src/mongo/db/s/shard_collection_legacy.cpp')
-rw-r--r--src/mongo/db/s/shard_collection_legacy.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/mongo/db/s/shard_collection_legacy.cpp b/src/mongo/db/s/shard_collection_legacy.cpp
index 0957ac63103..90273113961 100644
--- a/src/mongo/db/s/shard_collection_legacy.cpp
+++ b/src/mongo/db/s/shard_collection_legacy.cpp
@@ -492,7 +492,6 @@ CreateCollectionResponse shardCollection(OperationContext* opCtx,
const ShardsvrShardCollectionRequest& request,
const ShardId& dbPrimaryShardId,
bool mustTakeDistLock) {
- CreateCollectionResponse shardCollectionResponse;
// Fast check for whether the collection is already sharded without taking any locks
if (auto createCollectionResponseOpt =
checkIfCollectionAlreadyShardedWithSameOptions(opCtx, request)) {
@@ -538,6 +537,8 @@ CreateCollectionResponse shardCollection(OperationContext* opCtx,
serverGlobalParams.featureCompatibility);
}
+ CreateCollectionResponse shardCollectionResponse;
+
{
pauseShardCollectionBeforeCriticalSection.pauseWhileSet();
@@ -619,8 +620,6 @@ CreateCollectionResponse shardCollection(OperationContext* opCtx,
targetState = calculateTargetState(opCtx, nss, request);
- shardCollectionResponse.setCollectionUUID(targetState->uuid);
-
splitPolicy =
InitialSplitPolicy::calculateOptimizationStrategy(opCtx,
targetState->shardKeyPattern,
@@ -641,6 +640,7 @@ CreateCollectionResponse shardCollection(OperationContext* opCtx,
// There must be at least one chunk.
invariant(initialChunks.chunks.size());
+ shardCollectionResponse.setCollectionUUID(targetState->uuid);
shardCollectionResponse.setCollectionVersion(
initialChunks.chunks[initialChunks.chunks.size() - 1].getVersion());
@@ -673,7 +673,6 @@ CreateCollectionResponse shardCollection(OperationContext* opCtx,
"namespace"_attr = nss,
"initialCollectionVersion"_attr = initialChunks.collVersion());
-
ShardingLogging::get(opCtx)->logChange(
opCtx,
"shardCollection.end",
@@ -692,7 +691,7 @@ CreateCollectionResponse shardCollectionLegacy(OperationContext* opCtx,
const BSONObj& cmdObj,
bool requestFromCSRS) {
auto request = ShardsvrShardCollectionRequest::parse(
- IDLParserErrorContext("_shardsvrShardCollection"), cmdObj);
+ IDLParserErrorContext("shardCollectionLegacy"), cmdObj);
if (!request.getCollation())
request.setCollation(BSONObj());
if (!request.getCollation()->isEmpty()) {