From 43441676092ae87f4d0cc1bf81877f9610149454 Mon Sep 17 00:00:00 2001 From: Andy Schwerin Date: Wed, 28 Jun 2017 17:13:47 -0400 Subject: SERVER-29817 Use hinted insert when building chunkRangeMap --- src/mongo/s/chunk_manager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/mongo/s') diff --git a/src/mongo/s/chunk_manager.cpp b/src/mongo/s/chunk_manager.cpp index d07dc9a66eb..1b09f52f577 100644 --- a/src/mongo/s/chunk_manager.cpp +++ b/src/mongo/s/chunk_manager.cpp @@ -380,14 +380,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 -- cgit v1.2.1