diff options
Diffstat (limited to 'src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp')
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp index d622162ef09..a9e62c5a472 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp @@ -1713,13 +1713,18 @@ void ShardingCatalogManager::splitOrMarkJumbo(OperationContext* opCtx, Grid::get(opCtx)->getBalancerConfiguration()->getMaxChunkSizeBytes()); }(); - const auto splitPoints = uassertStatusOK( + // Limit the search to one split point: this code path is reached when a migration fails due + // to ErrorCodes::ChunkTooBig. In case there is a too frequent shard key, only select the + // next key in order to split the range in jumbo chunk + remaining range. + const int limit = 1; + auto splitPoints = uassertStatusOK( shardutil::selectChunkSplitPoints(opCtx, chunk.getShardId(), nss, cm.getShardKeyPattern(), ChunkRange(chunk.getMin(), chunk.getMax()), - maxChunkSizeBytes)); + maxChunkSizeBytes, + limit)); if (splitPoints.empty()) { LOGV2(21873, @@ -1771,6 +1776,9 @@ void ShardingCatalogManager::splitOrMarkJumbo(OperationContext* opCtx, return; } + // Resize the vector because in multiversion scenarios the `autoSplitVector` command may end + // up ignoring the `limit` parameter and returning the whole list of split points. + splitPoints.resize(limit); uassertStatusOK( shardutil::splitChunkAtMultiplePoints(opCtx, chunk.getShardId(), |