diff options
author | Paolo Polato <paolo.polato@mongodb.com> | 2022-07-28 12:58:21 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-23 08:51:50 +0000 |
commit | a1051719e1a61b47396b924732e20490f17472b5 (patch) | |
tree | d34961a8dc7c51917bdc6db343e154d6c8881d15 | |
parent | 8c06dd4e33cad4fe35df4dbd23454ed9d88566fe (diff) | |
download | mongo-a1051719e1a61b47396b924732e20490f17472b5.tar.gz |
SERVER-68126 Check constraints for maxChunkSize param in auto/splitVector commands
(cherry picked from commit b9f4378d3d65352e208c7f0e46e181e815251780)
-rw-r--r-- | src/mongo/db/s/auto_split_vector_command.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/s/split_vector_command.cpp | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/mongo/db/s/auto_split_vector_command.cpp b/src/mongo/db/s/auto_split_vector_command.cpp index 821527cac7d..18cdbd9cef6 100644 --- a/src/mongo/db/s/auto_split_vector_command.cpp +++ b/src/mongo/db/s/auto_split_vector_command.cpp @@ -39,7 +39,8 @@ namespace mongo { namespace { -static constexpr int64_t kSmallestChunkSizeSupported = 1024 * 1024; +static constexpr int64_t kSmallestChunkSizeBytesSupported = 1024 * 1024; +static constexpr int64_t kBiggestChunkSizeBytesSupported = 1024 * 1024 * 1024; class AutoSplitVectorCommand final : public TypedCommand<AutoSplitVectorCommand> { public: @@ -75,9 +76,11 @@ public: const auto& req = request(); uassert(ErrorCodes::ErrorCodes::InvalidOptions, - str::stream() << "maxChunksSizeBytes cannot be smaller than " - << kSmallestChunkSizeSupported, - req.getMaxChunkSizeBytes() >= kSmallestChunkSizeSupported); + str::stream() << "maxChunksSizeBytes must lie within the range [" + << kSmallestChunkSizeBytesSupported / (1024 * 1024) << "MB, " + << kBiggestChunkSizeBytesSupported / (1024 * 1024) << "MB]", + req.getMaxChunkSizeBytes() >= kSmallestChunkSizeBytesSupported && + req.getMaxChunkSizeBytes() <= kBiggestChunkSizeBytesSupported); auto [splitPoints, continuation] = autoSplitVector(opCtx, ns(), diff --git a/src/mongo/db/s/split_vector_command.cpp b/src/mongo/db/s/split_vector_command.cpp index b485c08361c..2fc9963b133 100644 --- a/src/mongo/db/s/split_vector_command.cpp +++ b/src/mongo/db/s/split_vector_command.cpp @@ -137,17 +137,16 @@ public: // Prevent maxChunkSizeBytes overflow. Check aimed to avoid fuzzer failures // since users are definitely not expected to specify maxChunkSize in exabytes. uassert(ErrorCodes::InvalidOptions, - str::stream() - << "The specified maxChunkSize in MB is too big: " << maxChunkSizeMB, - maxChunkSizeMB <= (LLONG_MAX >> 20)); + str::stream() << "maxChunkSize must lie within the range [1MB, 1024MB]", + maxChunkSizeMB >= 1 && maxChunkSizeMB <= 1024); ret = maxChunkSizeMB << 20; } else if (maxSizeBytesElem.isNumber()) { ret = maxSizeBytesElem.safeNumberLong(); + uassert(ErrorCodes::InvalidOptions, + "The specified max chunk size must lie within the range [1MB, 1024MB]", + *ret >= 1024 * 1024 && *ret <= 1024 * 1024 * 1024); } - uassert(ErrorCodes::InvalidOptions, - "The specified max chunk size must be at least 1MB", - ret == boost::none || *ret >= 1024 * 1024); return ret; }(); |