diff options
author | Paolo Polato <paolo.polato@mongodb.com> | 2022-02-10 13:41:13 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-10 14:15:25 +0000 |
commit | d018b7e964dafa5085152af03916bde0ac74f947 (patch) | |
tree | 5111f6c4a94ecdce8785d6d3bc8e81fc582234cc /src/mongo/db/s/chunk_splitter.cpp | |
parent | 9b2fe8666c8a633ed141b86676116094d2a468cb (diff) | |
download | mongo-d018b7e964dafa5085152af03916bde0ac74f947.tar.gz |
SERVER-63203 Do not fail chunk split if more than 8192 points are requested
Diffstat (limited to 'src/mongo/db/s/chunk_splitter.cpp')
-rw-r--r-- | src/mongo/db/s/chunk_splitter.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/mongo/db/s/chunk_splitter.cpp b/src/mongo/db/s/chunk_splitter.cpp index 54a849f8b93..f26341fc66e 100644 --- a/src/mongo/db/s/chunk_splitter.cpp +++ b/src/mongo/db/s/chunk_splitter.cpp @@ -52,6 +52,7 @@ #include "mongo/s/config_server_client.h" #include "mongo/s/grid.h" #include "mongo/s/shard_key_pattern.h" +#include "mongo/s/shard_util.h" #include "mongo/util/assert_util.h" namespace mongo { @@ -84,22 +85,23 @@ Status splitChunkAtMultiplePoints(OperationContext* opCtx, const ShardKeyPattern& shardKeyPattern, const ChunkVersion& collectionVersion, const ChunkRange& chunkRange, - const std::vector<BSONObj>& splitPoints) { + std::vector<BSONObj>&& splitPoints) { invariant(!splitPoints.empty()); - const size_t kMaxSplitPoints = 8192; - - if (splitPoints.size() > kMaxSplitPoints) { - return {ErrorCodes::BadValue, - str::stream() << "Cannot split chunk in more than " << kMaxSplitPoints - << " parts at a time."}; + if (splitPoints.size() > shardutil::kMaxSplitPoints) { + LOGV2_WARNING(6320301, + "Unable to apply all the split points received. Only the first " + "kMaxSplitPoints will be processed", + "numSplitPointsReceived"_attr = splitPoints.size(), + "kMaxSplitPoints"_attr = shardutil::kMaxSplitPoints); + splitPoints.resize(shardutil::kMaxSplitPoints); } return splitChunk(opCtx, nss, shardKeyPattern.toBSON(), chunkRange, - splitPoints, + std::move(splitPoints), shardId.toString(), collectionVersion.epoch(), true /* fromChunkSplitter */) @@ -393,13 +395,15 @@ void ChunkSplitter::_runAutosplit(std::shared_ptr<ChunkSplitStateDriver> chunkSp } } + auto numSplitPoints = splitPoints.size(); + uassertStatusOK(splitChunkAtMultiplePoints(opCtx.get(), chunk.getShardId(), nss, shardKeyPattern, cm.getVersion(), chunk.getRange(), - splitPoints)); + std::move(splitPoints))); chunkSplitStateDriver->commitSplit(); const bool shouldBalance = isAutoBalanceEnabled(opCtx.get(), nss, balancerConfig); @@ -412,7 +416,7 @@ void ChunkSplitter::_runAutosplit(std::shared_ptr<ChunkSplitStateDriver> chunkSp "minKey"_attr = redact(chunk.getMin()), "maxKey"_attr = redact(chunk.getMax()), "lastmod"_attr = chunk.getLastmod(), - "splitPoints"_attr = splitPoints.size(), + "splitPoints"_attr = numSplitPoints, "maxChunkSizeBytes"_attr = maxChunkSizeBytes, "extraInfo"_attr = (topChunkMinKey.isEmpty() ? "" |