summaryrefslogtreecommitdiff
path: root/src/mongo/s/write_ops
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2019-11-04 23:51:35 +0000
committerevergreen <evergreen@mongodb.com>2019-11-04 23:51:35 +0000
commitf884772e3e757aa7c64d71f200680ce9e0b91325 (patch)
tree633c4b55655198e7175ff662a86b41f76e8eba24 /src/mongo/s/write_ops
parenta417e979908af2124b990d68a22c437005877790 (diff)
downloadmongo-f884772e3e757aa7c64d71f200680ce9e0b91325.tar.gz
SERVER-44175 Reject shard key array descendants
Diffstat (limited to 'src/mongo/s/write_ops')
-rw-r--r--src/mongo/s/write_ops/chunk_manager_targeter.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/s/write_ops/chunk_manager_targeter.cpp b/src/mongo/s/write_ops/chunk_manager_targeter.cpp
index ac25a77b085..0d8cce10233 100644
--- a/src/mongo/s/write_ops/chunk_manager_targeter.cpp
+++ b/src/mongo/s/write_ops/chunk_manager_targeter.cpp
@@ -385,6 +385,13 @@ StatusWith<ShardEndpoint> ChunkManagerTargeter::targetInsert(OperationContext* o
if (_routingInfo->cm()) {
shardKey = _routingInfo->cm()->getShardKeyPattern().extractShardKeyFromDoc(doc);
+ // The shard key would only be empty after extraction if we encountered an error case,
+ // such as the shard key possessing an array value or array descendants. If the shard key
+ // presented to the targeter was empty, we would emplace the missing fields, and the
+ // extracted key here would *not* be empty.
+ uassert(ErrorCodes::ShardKeyNotFound,
+ "Shard key cannot contain array values or array descendants.",
+ !shardKey.isEmpty());
}
// Target the shard key or database primary