summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorPaolo Polato <paolo.polato@mongodb.com>2022-04-19 08:10:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-19 08:38:38 +0000
commit9c4c52c6b1886b58b75fd16c46cac712775a34cb (patch)
tree19561204863de0e94448b1ec68b4a53cf472e100 /src/mongo/db
parent71b0968070ba18cb59f285f3e0c007e935599d59 (diff)
downloadmongo-9c4c52c6b1886b58b75fd16c46cac712775a34cb.tar.gz
SERVER-62205 Check maxChunkSize parameter in (auto)splitVector requests
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/s/auto_split_vector_command.cpp7
-rw-r--r--src/mongo/db/s/split_vector_command.cpp5
2 files changed, 12 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 32275403eff..1dd6b15df10 100644
--- a/src/mongo/db/s/auto_split_vector_command.cpp
+++ b/src/mongo/db/s/auto_split_vector_command.cpp
@@ -39,6 +39,8 @@
namespace mongo {
namespace {
+static constexpr int64_t kSmallestChunkSizeSupported = 1024 * 1024;
+
class AutoSplitVectorCommand final : public TypedCommand<AutoSplitVectorCommand> {
public:
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
@@ -67,6 +69,11 @@ public:
const auto& req = request();
+ uassert(ErrorCodes::ErrorCodes::InvalidOptions,
+ str::stream() << "maxChunksSizeBytes cannot be smaller than "
+ << kSmallestChunkSizeSupported,
+ req.getMaxChunkSizeBytes() >= kSmallestChunkSizeSupported);
+
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 6efe68ca5f2..3d2ba885bb7 100644
--- a/src/mongo/db/s/split_vector_command.cpp
+++ b/src/mongo/db/s/split_vector_command.cpp
@@ -133,6 +133,11 @@ public:
maxChunkSizeBytes = maxSizeBytesElem.numberLong();
}
+ if (maxChunkSizeBytes.is_initialized() && *maxChunkSizeBytes < 1024 * 1024) {
+ errmsg = "maxChunkSize must be at least 1MB";
+ return false;
+ }
+
auto splitKeys = splitVector(opCtx,
nss,
keyPattern,