diff options
author | Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com> | 2021-12-14 13:08:43 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-14 13:39:13 +0000 |
commit | bf7adca3bd56959f320eccb610668fe21c196243 (patch) | |
tree | 8a9c52e7d70f80a6a7e17f7afbc752ac97f1afc2 /src/mongo/db/s/auto_split_vector.cpp | |
parent | a7769499d4f46deb5c52cacad15c499a70e42683 (diff) | |
download | mongo-bf7adca3bd56959f320eccb610668fe21c196243.tar.gz |
SERVER-58750 get rid of unnecessary sorting of split keys
Diffstat (limited to 'src/mongo/db/s/auto_split_vector.cpp')
-rw-r--r-- | src/mongo/db/s/auto_split_vector.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mongo/db/s/auto_split_vector.cpp b/src/mongo/db/s/auto_split_vector.cpp index 5b964007714..062fb26cef8 100644 --- a/src/mongo/db/s/auto_split_vector.cpp +++ b/src/mongo/db/s/auto_split_vector.cpp @@ -240,7 +240,11 @@ std::vector<BSONObj> autoSplitVector(OperationContext* opCtx, if (++numScannedKeys >= maxDocsPerChunk) { currentKey = orderShardKeyFields(keyPattern, currentKey); - if (currentKey.woCompare(lastSplitPoint) == 0) { + const auto compareWithPreviousSplitPoint = currentKey.woCompare(lastSplitPoint); + dassert(compareWithPreviousSplitPoint >= 0, + str::stream() << "Found split key smaller then the last one: " << currentKey + << " < " << lastSplitPoint); + if (compareWithPreviousSplitPoint == 0) { // Do not add again the same split point in case of frequent shard key. tooFrequentKeys.insert(currentKey.getOwned()); continue; @@ -310,6 +314,10 @@ std::vector<BSONObj> autoSplitVector(OperationContext* opCtx, const auto compareWithPreviousSplitPoint = currentKey.woCompare(previousSplitPoint); + + dassert(compareWithPreviousSplitPoint >= 0, + str::stream() << "Found split key smaller then the previous one: " + << currentKey << " < " << previousSplitPoint); if (compareWithPreviousSplitPoint > 0) { const auto additionalKeySize = currentKey.objsize() + estimatedAdditionalBytesPerItemInBSONArray; @@ -362,11 +370,6 @@ std::vector<BSONObj> autoSplitVector(OperationContext* opCtx, "duration"_attr = Milliseconds(elapsedMillisToFindSplitPoints)); } - // TODO SERVER-58750: investigate if it is really needed to sort the vector - // Make sure splitKeys is in ascending order - std::sort( - splitKeys.begin(), splitKeys.end(), SimpleBSONObjComparator::kInstance.makeLessThan()); - return splitKeys; } |