diff options
author | Paolo Polato <paolo.polato@mongodb.com> | 2022-04-19 08:10:24 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-04-19 08:38:38 +0000 |
commit | 9c4c52c6b1886b58b75fd16c46cac712775a34cb (patch) | |
tree | 19561204863de0e94448b1ec68b4a53cf472e100 | |
parent | 71b0968070ba18cb59f285f3e0c007e935599d59 (diff) | |
download | mongo-9c4c52c6b1886b58b75fd16c46cac712775a34cb.tar.gz |
SERVER-62205 Check maxChunkSize parameter in (auto)splitVector requests
-rw-r--r-- | jstests/sharding/libs/mongos_api_params_util.js | 2 | ||||
-rw-r--r-- | src/mongo/db/s/auto_split_vector_command.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/s/split_vector_command.cpp | 5 |
3 files changed, 13 insertions, 1 deletions
diff --git a/jstests/sharding/libs/mongos_api_params_util.js b/jstests/sharding/libs/mongos_api_params_util.js index 4f144479c62..63e4f3e1ae4 100644 --- a/jstests/sharding/libs/mongos_api_params_util.js +++ b/jstests/sharding/libs/mongos_api_params_util.js @@ -1258,7 +1258,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 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, |