diff options
author | Benety Goh <benety@mongodb.com> | 2021-06-03 18:22:55 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-03 22:57:37 +0000 |
commit | 368d6ce6986680211fd4c09bb23431d08bb4e297 (patch) | |
tree | 0299e238c6430c5ff733631a8dbe4f334f19c572 /src/mongo/db/s/split_chunk.cpp | |
parent | ccdda22e09a877afb86de220ccbb5434ea596367 (diff) | |
download | mongo-368d6ce6986680211fd4c09bb23431d08bb4e297.tar.gz |
SERVER-57127 IndexCatalog::findShardKeyPrefixedIndex() accepts CollectionPtr
Diffstat (limited to 'src/mongo/db/s/split_chunk.cpp')
-rw-r--r-- | src/mongo/db/s/split_chunk.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mongo/db/s/split_chunk.cpp b/src/mongo/db/s/split_chunk.cpp index d8e8cf9af90..9cd07adae36 100644 --- a/src/mongo/db/s/split_chunk.cpp +++ b/src/mongo/db/s/split_chunk.cpp @@ -232,9 +232,10 @@ StatusWith<boost::optional<ChunkRange>> splitChunk(OperationContext* opCtx, // Allow multiKey based on the invariant that shard keys must be single-valued. Therefore, // any multi-key index prefixed by shard key cannot be multikey over the shard key fields. - const IndexDescriptor* idx = - collection->getIndexCatalog()->findShardKeyPrefixedIndex(opCtx, keyPatternObj, false); - if (!idx) { + auto catalog = collection->getIndexCatalog(); + auto shardKeyIdx = catalog->findShardKeyPrefixedIndex( + opCtx, *collection, keyPatternObj, /*requireSingleKey=*/false); + if (!shardKeyIdx) { return boost::optional<ChunkRange>(boost::none); } @@ -248,10 +249,10 @@ StatusWith<boost::optional<ChunkRange>> splitChunk(OperationContext* opCtx, KeyPattern shardKeyPattern(keyPatternObj); if (shardKeyPattern.globalMax().woCompare(backChunk.getMax()) == 0 && - checkIfSingleDoc(opCtx, collection.getCollection(), idx, &backChunk)) { + checkIfSingleDoc(opCtx, collection.getCollection(), shardKeyIdx, &backChunk)) { return boost::optional<ChunkRange>(ChunkRange(backChunk.getMin(), backChunk.getMax())); } else if (shardKeyPattern.globalMin().woCompare(frontChunk.getMin()) == 0 && - checkIfSingleDoc(opCtx, collection.getCollection(), idx, &frontChunk)) { + checkIfSingleDoc(opCtx, collection.getCollection(), shardKeyIdx, &frontChunk)) { return boost::optional<ChunkRange>(ChunkRange(frontChunk.getMin(), frontChunk.getMax())); } return boost::optional<ChunkRange>(boost::none); |