summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2017-08-16 18:49:27 -0400
committerEsha Maharishi <esha.maharishi@mongodb.com>2017-08-17 09:41:17 -0400
commitebd7eef1dbc0e61266e26b9511f426b44d93e92a (patch)
treee22d731c9db9b9e0e65d43e52c38cb70a0d59593
parent07197eb1c413b3ed94ce5633036ee0d64853cf36 (diff)
downloadmongo-ebd7eef1dbc0e61266e26b9511f426b44d93e92a.tar.gz
SERVER-30703 make _configsvrShardCollection return the newly sharded collection's UUID
-rw-r--r--src/mongo/db/s/config/configsvr_shard_collection_command.cpp15
-rw-r--r--src/mongo/s/commands/cluster_map_reduce_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_shard_collection_cmd.cpp2
-rw-r--r--src/mongo/s/request_types/shard_collection.idl16
-rw-r--r--src/mongo/util/uuid.h2
5 files changed, 26 insertions, 11 deletions
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 d041d40aabd..fe2aae3e918 100644
--- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
@@ -132,7 +132,7 @@ void validateAndDeduceFullRequestOptions(OperationContext* opCtx,
const ShardKeyPattern& shardKeyPattern,
int numShards,
ScopedDbConnection& conn,
- ConfigsvrShardCollection* request) {
+ ConfigsvrShardCollectionRequest* request) {
uassert(
ErrorCodes::InvalidOptions, "cannot have empty shard key", !request->getKey().isEmpty());
@@ -249,7 +249,7 @@ void validateAndDeduceFullRequestOptions(OperationContext* opCtx,
*/
bool checkIfAlreadyShardedWithSameOptions(OperationContext* opCtx,
const NamespaceString& nss,
- const ConfigsvrShardCollection& request) {
+ const ConfigsvrShardCollectionRequest& request) {
auto catalogCache = Grid::get(opCtx)->catalogCache();
// Until all metadata commands are on the config server, the CatalogCache on the config
@@ -301,7 +301,7 @@ void validateShardKeyAgainstExistingIndexes(OperationContext* opCtx,
const ShardKeyPattern& shardKeyPattern,
const std::shared_ptr<Shard> primaryShard,
ScopedDbConnection& conn,
- const ConfigsvrShardCollection& request) {
+ const ConfigsvrShardCollectionRequest& request) {
// The proposed shard key must be validated against the set of existing indexes.
// In particular, we must ensure the following constraints
//
@@ -452,7 +452,7 @@ void determinePresplittingPoints(OperationContext* opCtx,
bool isEmpty,
const BSONObj& proposedKey,
const ShardKeyPattern& shardKeyPattern,
- const ConfigsvrShardCollection& request,
+ const ConfigsvrShardCollectionRequest& request,
std::vector<BSONObj>* initSplits,
std::vector<BSONObj>* allSplits) {
auto numChunks = request.getNumInitialChunks();
@@ -732,8 +732,8 @@ public:
serverGlobalParams.clusterRole == ClusterRole::ConfigServer);
const NamespaceString nss(parseNs(dbname, cmdObj));
- auto request = ConfigsvrShardCollection::parse(
- IDLParserErrorContext("ConfigsvrShardCollection"), cmdObj);
+ auto request = ConfigsvrShardCollectionRequest::parse(
+ IDLParserErrorContext("ConfigsvrShardCollectionRequest"), cmdObj);
auto const catalogManager = ShardingCatalogManager::get(opCtx);
auto const catalogCache = Grid::get(opCtx)->catalogCache();
@@ -823,6 +823,9 @@ public:
initSplits,
distributeInitialChunks);
result << "collectionsharded" << nss.ns();
+ if (uuid) {
+ result << "collectionUUID" << *uuid;
+ }
// Make sure the cached metadata for the collection knows that we are now sharded
catalogCache->invalidateShardedCollection(nss);
diff --git a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
index 78ce450a3d6..eb5b42e2d0c 100644
--- a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
+++ b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
@@ -641,7 +641,7 @@ private:
// collection the next time it's accessed, even if we receive a failure, e.g. NetworkError.
ON_BLOCK_EXIT([catalogCache, nss] { catalogCache->invalidateShardedCollection(nss); });
- ConfigsvrShardCollection configShardCollRequest;
+ ConfigsvrShardCollectionRequest configShardCollRequest;
configShardCollRequest.set_configsvrShardCollection(nss);
configShardCollRequest.setKey(BSON("_id" << 1));
configShardCollRequest.setUnique(true);
diff --git a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
index 220be51da62..b2566ec7584 100644
--- a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
+++ b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
@@ -112,7 +112,7 @@ public:
auto shardCollRequest =
ShardCollection::parse(IDLParserErrorContext("ShardCollection"), cmdObj);
- ConfigsvrShardCollection configShardCollRequest;
+ ConfigsvrShardCollectionRequest configShardCollRequest;
configShardCollRequest.set_configsvrShardCollection(nss);
configShardCollRequest.setKey(shardCollRequest.getKey());
configShardCollRequest.setUnique(shardCollRequest.getUnique());
diff --git a/src/mongo/s/request_types/shard_collection.idl b/src/mongo/s/request_types/shard_collection.idl
index 054b633996e..6289b22e2fb 100644
--- a/src/mongo/s/request_types/shard_collection.idl
+++ b/src/mongo/s/request_types/shard_collection.idl
@@ -61,8 +61,8 @@ structs:
description: "The collation to use for the shard key index."
optional: true
- ConfigsvrShardCollection:
- description: "The internal shardCollection command on the config server"
+ ConfigsvrShardCollectionRequest:
+ description: "The request format of the internal shardCollection command on the config server"
strict: false
fields:
_configsvrShardCollection:
@@ -88,3 +88,15 @@ structs:
type: object
description: "The collation to use for the shard key index."
optional: true
+
+ ConfigsvrShardCollectionResponse:
+ description: "The response format of the internal shardCollection command on the config server"
+ strict: false
+ fields:
+ collectionsharded:
+ type: string
+ description: "The name of the collection that just got sharded."
+ collectionUUID:
+ type: uuid
+ description: "The UUID of the collection that just got sharded."
+ optional: true
diff --git a/src/mongo/util/uuid.h b/src/mongo/util/uuid.h
index 8436f5936ba..b4b8df30e90 100644
--- a/src/mongo/util/uuid.h
+++ b/src/mongo/util/uuid.h
@@ -53,7 +53,7 @@ class UUID {
using UUIDStorage = std::array<unsigned char, 16>;
// Make the IDL generated parser a friend
- friend class ConfigsvrShardCollection;
+ friend class ConfigsvrShardCollectionResponse;
friend class One_UUID;
friend class LogicalSessionId;
friend class LogicalSessionToClient;