diff options
author | Ted Tuckman <ted.tuckman@mongodb.com> | 2020-02-07 14:23:25 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-13 14:22:39 +0000 |
commit | 173e12f195cf456c6f08d82131256d625c1f583f (patch) | |
tree | 361bea7a75bdf7f30711173482e928eb70bed0ee /src | |
parent | bc9eb303c38102f8e50f18e9506ef9f8d3ff19b1 (diff) | |
download | mongo-173e12f195cf456c6f08d82131256d625c1f583f.tar.gz |
SERVER-45526 Reclaim lookup performance
Diffstat (limited to 'src')
6 files changed, 18 insertions, 14 deletions
diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp index b95439e7240..ba215f30972 100644 --- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp +++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp @@ -152,13 +152,6 @@ CommonMongodProcessInterface::createTransactionHistoryIterator(repl::OpTime time new TransactionHistoryIterator(time, permitYield)); } -bool CommonMongodProcessInterface::isSharded(OperationContext* opCtx, const NamespaceString& nss) { - Lock::DBLock dbLock(opCtx, nss.db(), MODE_IS); - Lock::CollectionLock collLock(opCtx, nss, MODE_IS); - const auto metadata = CollectionShardingState::get(opCtx, nss)->getCurrentMetadata(); - return metadata->isSharded(); -} - std::vector<Document> CommonMongodProcessInterface::getIndexStats(OperationContext* opCtx, const NamespaceString& ns, StringData host, diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h index 898d5380d13..bbf414a5224 100644 --- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h +++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h @@ -55,12 +55,6 @@ public: std::unique_ptr<TransactionHistoryIteratorBase> createTransactionHistoryIterator( repl::OpTime time) const final; - /** - * Note: Information returned can be stale. Caller should always attach shardVersion when - * sending request against nss based on this information. - */ - bool isSharded(OperationContext* opCtx, const NamespaceString& nss) final; - std::vector<Document> getIndexStats(OperationContext* opCtx, const NamespaceString& ns, StringData host, diff --git a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h index 7179a05cb21..e697ed0d3bc 100644 --- a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h +++ b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h @@ -128,7 +128,8 @@ public: /** * Note that in some rare cases this could return a false negative but will never return a false * positive. This method will be fixed in the future once it becomes possible to avoid false - * negatives. + * negatives. Caller should always attach shardVersion when sending request against nss based + * on this information. */ virtual bool isSharded(OperationContext* opCtx, const NamespaceString& ns) = 0; diff --git a/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.h b/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.h index cd58220c9f0..c79db4bbcf6 100644 --- a/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.h +++ b/src/mongo/db/pipeline/process_interface/non_shardsvr_process_interface.h @@ -47,6 +47,10 @@ public: virtual ~NonShardServerProcessInterface() = default; + bool isSharded(OperationContext* opCtx, const NamespaceString& nss) final { + return false; + } + Status insert(const boost::intrusive_ptr<ExpressionContext>& expCtx, const NamespaceString& ns, std::vector<BSONObj>&& objs, diff --git a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp index dcd5179def4..087a258a3fa 100644 --- a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp +++ b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp @@ -73,6 +73,13 @@ void attachWriteConcern(BatchedCommandRequest* request, const WriteConcernOption } // namespace +bool ShardServerProcessInterface::isSharded(OperationContext* opCtx, const NamespaceString& nss) { + Lock::DBLock dbLock(opCtx, nss.db(), MODE_IS); + Lock::CollectionLock collLock(opCtx, nss, MODE_IS); + const auto metadata = CollectionShardingState::get(opCtx, nss)->getCurrentMetadata(); + return metadata->isSharded(); +} + void ShardServerProcessInterface::checkRoutingInfoEpochOrThrow( const boost::intrusive_ptr<ExpressionContext>& expCtx, const NamespaceString& nss, diff --git a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.h b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.h index a7fa2b9198d..4c411cad35b 100644 --- a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.h +++ b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.h @@ -42,6 +42,11 @@ class ShardServerProcessInterface final : public CommonMongodProcessInterface { public: using CommonMongodProcessInterface::CommonMongodProcessInterface; + /** + * Note: Information returned can be stale. Caller should always attach shardVersion when + * sending request against nss based on this information. + */ + bool isSharded(OperationContext* opCtx, const NamespaceString& nss) final; void checkRoutingInfoEpochOrThrow(const boost::intrusive_ptr<ExpressionContext>& expCtx, const NamespaceString& nss, ChunkVersion targetCollectionVersion) const final; |