summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/s/chunk_manager.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mongo/s/chunk_manager.cpp b/src/mongo/s/chunk_manager.cpp
index ecc743fd63f..70a79eee26f 100644
--- a/src/mongo/s/chunk_manager.cpp
+++ b/src/mongo/s/chunk_manager.cpp
@@ -383,14 +383,17 @@ ChunkManager::ChunkMapViews ChunkManager::_constructChunkMapViews(const OID& epo
const BSONObj rangeMin = firstChunkInRange->getMin();
const BSONObj rangeMax = rangeLast->second->getMax();
- const auto insertResult = chunkRangeMap.insert(std::make_pair(
- rangeMax, ShardAndChunkRange{{rangeMin, rangeMax}, firstChunkInRange->getShardId()}));
+ const auto oldSize = chunkRangeMap.size();
+ const auto insertIterator = chunkRangeMap.insert(
+ chunkRangeMap.end(),
+ std::make_pair(
+ rangeMax,
+ ShardAndChunkRange{{rangeMin, rangeMax}, firstChunkInRange->getShardId()}));
uassert(ErrorCodes::ConflictingOperationInProgress,
str::stream() << "Metadata contains two chunks with the same max value "
<< rangeMax,
- insertResult.second);
+ oldSize + 1 == chunkRangeMap.size());
- const auto& insertIterator = insertResult.first;
if (insertIterator != chunkRangeMap.begin()) {
// Make sure there are no gaps in the ranges