summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorJamie Heppenstall <jamie.heppenstall@mongodb.com>2019-08-21 12:52:34 -0400
committerJamie Heppenstall <jamie.heppenstall@mongodb.com>2019-08-21 14:23:03 -0400
commit0da2c13f7f39f9568b317f1ea6dc73252aeeaf2f (patch)
tree06bc5a001ee1f2f0d8ee671fcb172780968f91a4 /src/mongo
parentd0662ae08dfff18472f5e91a3baee3687a33d7ea (diff)
downloadmongo-0da2c13f7f39f9568b317f1ea6dc73252aeeaf2f.tar.gz
SERVER-42950 Make _configsvrRefineCollectionShardKey return if shard key is already refined before checking for StaleEpoch
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp23
1 files changed, 11 insertions, 12 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 acddb4be4e8..0020ae529b4 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
@@ -83,8 +83,9 @@ public:
"refineCollectionShardKey",
DistLockManager::kDefaultLockTimeout)));
- // Validate the given namespace is (i) sharded and (ii) has the same epoch as the router
- // that received refineCollectionShardKey had in its routing table cache.
+ // Validate the given namespace is (i) sharded, (ii) doesn't already have the proposed
+ // key, and (iii) has the same epoch as the router that received
+ // refineCollectionShardKey had in its routing table cache.
const auto collStatus =
catalogClient->getCollection(opCtx, nss, repl::ReadConcernLevel::kLocalReadConcern);
@@ -94,17 +95,7 @@ public:
collStatus != ErrorCodes::NamespaceNotFound);
const auto collType = uassertStatusOK(collStatus).value;
-
- uassert(ErrorCodes::StaleEpoch,
- str::stream()
- << "refineCollectionShardKey namespace " << nss.toString()
- << " has a different epoch than mongos had in its routing table cache",
- request().getEpoch() == collType.getEpoch());
-
const auto oldShardKeyPattern = ShardKeyPattern(collType.getKeyPattern());
-
- // 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 proposedKey = request().getKey().getOwned();
if (SimpleBSONObjComparator::kInstance.evaluate(oldShardKeyPattern.toBSON() ==
@@ -114,6 +105,14 @@ public:
return;
}
+ uassert(ErrorCodes::StaleEpoch,
+ str::stream()
+ << "refineCollectionShardKey namespace " << nss.toString()
+ << " has a different epoch than mongos had in its routing table cache",
+ request().getEpoch() == collType.getEpoch());
+
+ // 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,