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-07-28 13:31:30 +0000 |
commit | b9f4378d3d65352e208c7f0e46e181e815251780 (patch) | |
tree | 60a8c9f354b69215a9f9ea6ca0fc773704cd3542 | |
parent | 4e9dd74af2467b9c04e7014c0f754465321da8a9 (diff) | |
download | mongo-b9f4378d3d65352e208c7f0e46e181e815251780.tar.gz |
SERVER-68126 Check constraints for maxChunkSize param in auto/splitVector commands
-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 9844254520d..ba48fdffed8 100644 --- a/src/mongo/db/s/auto_split_vector_command.cpp +++ b/src/mongo/db/s/auto_split_vector_command.cpp @@ -41,7 +41,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: @@ -77,9 +78,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; }(); |