diff options
-rw-r--r-- | src/mongo/db/s/auto_split_vector_command.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/s/split_vector_command.cpp | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/s/auto_split_vector_command.cpp b/src/mongo/db/s/auto_split_vector_command.cpp index df88204dc0b..1aac404e8f1 100644 --- a/src/mongo/db/s/auto_split_vector_command.cpp +++ b/src/mongo/db/s/auto_split_vector_command.cpp @@ -36,6 +36,9 @@ namespace mongo { namespace { +static constexpr int64_t kSmallestChunkSizeBytesSupported = 1024 * 1024; +static constexpr int64_t kBiggestChunkSizeBytesSupported = 1024 * 1024 * 1024; + class AutoSplitVectorCommand final : public TypedCommand<AutoSplitVectorCommand> { public: AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { @@ -63,6 +66,13 @@ public: const auto& req = request(); + uassert(ErrorCodes::ErrorCodes::InvalidOptions, + str::stream() << "maxChunksSizeBytes must lie within the range [" + << kSmallestChunkSizeBytesSupported / (1024 * 1024) << "MB, " + << kBiggestChunkSizeBytesSupported / (1024 * 1024) << "MB]", + req.getMaxChunkSizeBytes() >= kSmallestChunkSizeBytesSupported && + req.getMaxChunkSizeBytes() <= kBiggestChunkSizeBytesSupported); + auto splitKeys = autoSplitVector(opCtx, ns(), req.getKeyPattern(), diff --git a/src/mongo/db/s/split_vector_command.cpp b/src/mongo/db/s/split_vector_command.cpp index 0b65dc3fc14..03c45cf4471 100644 --- a/src/mongo/db/s/split_vector_command.cpp +++ b/src/mongo/db/s/split_vector_command.cpp @@ -127,12 +127,20 @@ public: BSONElement maxSizeElem = jsobj["maxChunkSize"]; if (maxSizeElem.isNumber()) { maxChunkSize = maxSizeElem.numberLong(); + if (*maxChunkSize < 1 || *maxChunkSize > 1024) { + errmsg = "The specified max chunk size must lie within the range [1MB, 1024MB]"; + return false; + } } boost::optional<long long> maxChunkSizeBytes; maxSizeElem = jsobj["maxChunkSizeBytes"]; if (maxSizeElem.isNumber()) { maxChunkSizeBytes = maxSizeElem.numberLong(); + if (*maxChunkSizeBytes < 1024 * 1024 || *maxChunkSizeBytes > 1024 * 1024 * 1024) { + errmsg = "The specified max chunk size must lie within the range [1MB, 1024MB]"; + return false; + } } auto statusWithSplitKeys = splitVector(opCtx, |