summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Polato <paolo.polato@mongodb.com>2022-03-04 15:13:09 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-24 21:44:33 +0000
commit090e7a7e2e9ce027da9499464e6c270a1b2f81e1 (patch)
treeeccb9debf687b3435a50d0ed8d7d2ce7e2342969
parent462d3264fdded1859dab00cd96a7d585bcc5751b (diff)
downloadmongo-090e7a7e2e9ce027da9499464e6c270a1b2f81e1.tar.gz
SERVER-62205 Check maxChunkSize parameter in (auto)splitVector requests
(cherry picked from commit 46a82e8cd87b95cf404420916246e7af8b96850b)
-rw-r--r--jstests/sharding/libs/mongos_api_params_util.js2
-rw-r--r--src/mongo/db/s/auto_split_vector_command.cpp7
-rw-r--r--src/mongo/db/s/split_vector_command.cpp4
3 files changed, 10 insertions, 3 deletions
diff --git a/jstests/sharding/libs/mongos_api_params_util.js b/jstests/sharding/libs/mongos_api_params_util.js
index e22045f1761..2b99bc79d4b 100644
--- a/jstests/sharding/libs/mongos_api_params_util.js
+++ b/jstests/sharding/libs/mongos_api_params_util.js
@@ -1263,7 +1263,7 @@ let MongosAPIParametersUtil = (function() {
keyPattern: {_id: 1},
min: {_id: 0},
max: {_id: MaxKey},
- maxChunkSizeBytes: 1024
+ maxChunkSizeBytes: 1024 * 1024
})
}
},
diff --git a/src/mongo/db/s/auto_split_vector_command.cpp b/src/mongo/db/s/auto_split_vector_command.cpp
index 2b0657cc3ce..1748491cac6 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:
bool skipApiVersionCheck() const override {
@@ -72,6 +74,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 9754207a8bd..b485c08361c 100644
--- a/src/mongo/db/s/split_vector_command.cpp
+++ b/src/mongo/db/s/split_vector_command.cpp
@@ -146,8 +146,8 @@ public:
}
uassert(ErrorCodes::InvalidOptions,
- "The specified max chunk size must be greater than 0",
- ret == boost::none || *ret > 0);
+ "The specified max chunk size must be at least 1MB",
+ ret == boost::none || *ret >= 1024 * 1024);
return ret;
}();