diff options
author | Tommaso Tocci <tommaso.tocci@mongodb.com> | 2020-03-02 19:02:44 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-06 11:41:18 +0000 |
commit | a948595cc2c2a05d275802d6b176917b1374bb28 (patch) | |
tree | 63cfc92a9c78301df5d508ec08207f55f1824288 /src/mongo | |
parent | 1d6cd3e2fbe7b31fab7c6d2dc73587c40ec66d56 (diff) | |
download | mongo-a948595cc2c2a05d275802d6b176917b1374bb28.tar.gz |
SERVER-47104 Make upsert stage use OwnershipFilter instead of CollectionDescription
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/exec/upsert_stage.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mongo/db/exec/upsert_stage.cpp b/src/mongo/db/exec/upsert_stage.cpp index 0b34a223d0d..3f735981b18 100644 --- a/src/mongo/db/exec/upsert_stage.cpp +++ b/src/mongo/db/exec/upsert_stage.cpp @@ -148,13 +148,14 @@ void UpsertStage::_performInsert(BSONObj newDocument) { // throw so that MongoS can target the insert to the correct shard. if (_shouldCheckForShardKeyUpdate) { auto* const css = CollectionShardingState::get(opCtx(), collection()->ns()); - const auto& collDesc = css->getCollectionDescription(); + const auto collFilter = css->getOwnershipFilter( + opCtx(), CollectionShardingState::OrphanCleanupPolicy::kAllowOrphanCleanup); - if (collDesc.isSharded()) { - const ShardKeyPattern shardKeyPattern(collDesc.getKeyPattern()); + if (collFilter.isSharded()) { + const ShardKeyPattern shardKeyPattern(collFilter.getKeyPattern()); auto newShardKey = shardKeyPattern.extractShardKeyFromDoc(newDocument); - if (!collDesc->keyBelongsToMe(newShardKey)) { + if (!collFilter.keyBelongsToMe(newShardKey)) { // An attempt to upsert a document with a shard key value that belongs on another // shard must either be a retryable write or inside a transaction. uassert(ErrorCodes::IllegalOperation, |