summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2022-09-01 22:04:07 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-01 22:42:00 +0000
commit2f624f66f3044e7066d86420b2b6151a19947064 (patch)
tree307e95fd8624605257937a695652c81bd14d364f
parent82f8c7d7999603f7d8e5e03a49e25b3c4eba244e (diff)
downloadmongo-2f624f66f3044e7066d86420b2b6151a19947064.tar.gz
SERVER-69384 - Fix v5.0 legacy shardCollection path for implicitCreateIndex parameter
-rw-r--r--jstests/sharding/shard_collection_basic.js2
-rw-r--r--src/mongo/db/s/config/configsvr_shard_collection_command.cpp3
-rw-r--r--src/mongo/s/request_types/shard_collection.idl8
3 files changed, 12 insertions, 1 deletions
diff --git a/jstests/sharding/shard_collection_basic.js b/jstests/sharding/shard_collection_basic.js
index ccefece75f7..648fb4370bb 100644
--- a/jstests/sharding/shard_collection_basic.js
+++ b/jstests/sharding/shard_collection_basic.js
@@ -109,7 +109,7 @@ jsTestLog('Command should still verify index even if implicitlyCreateIndex is fa
assert.commandFailedWithCode(
mongos.adminCommand(
{shardCollection: kDbName + '.foo', key: {x: 1}, implicitlyCreateIndex: false}),
- 6373200);
+ [6373200, 6373201]);
//
// Test shardCollection's idempotency
diff --git a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
index b8fae536f71..853cc3aac70 100644
--- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
@@ -339,6 +339,9 @@ public:
shardsvrShardCollectionRequest.setCollation(request.getCollation());
shardsvrShardCollectionRequest.setGetUUIDfromPrimaryShard(
request.getGetUUIDfromPrimaryShard());
+ shardsvrShardCollectionRequest.setImplicitlyCreateIndex(request.getImplicitlyCreateIndex());
+ shardsvrShardCollectionRequest.setEnforceUniquenessCheck(
+ request.getEnforceUniquenessCheck());
auto cmdResponse = uassertStatusOK(primaryShard->runCommandWithFixedRetryAttempts(
opCtx,
diff --git a/src/mongo/s/request_types/shard_collection.idl b/src/mongo/s/request_types/shard_collection.idl
index 3ad8dda88d2..cd0b9962c81 100644
--- a/src/mongo/s/request_types/shard_collection.idl
+++ b/src/mongo/s/request_types/shard_collection.idl
@@ -70,6 +70,14 @@ structs:
type: bool
description: "Whether the collection should be created on the primary shard. This should only be false when used in mapReduce."
default: true
+ implicitlyCreateIndex:
+ description: "Creates an index on the shard key pattern if the collection is empty."
+ type: optionalBool
+ enforceUniquenessCheck:
+ description: >-
+ Controls whether this command verifies that any unique indexes are prefixed by the shard
+ key pattern if unique is true. If true then it will verify and if false then it won't.
+ type: optionalBool
ConfigsvrShardCollectionResponse:
description: "The response format of the internal shardCollection command on the config server"