From 02f873aa68c80f0b53f006addbf0a60aba6cc89c Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Mon, 16 Dec 2019 22:14:42 +0000 Subject: SERVER-44897 remove MongoProcessInterface::setOperationContext() --- src/mongo/db/pipeline/document_source_exchange_test.cpp | 13 +------------ src/mongo/db/pipeline/document_source_facet_test.cpp | 13 +------------ src/mongo/db/pipeline/document_source_out.cpp | 5 ----- src/mongo/db/pipeline/mongo_process_interface.h | 7 ------- src/mongo/db/pipeline/mongos_process_interface.h | 2 -- src/mongo/db/pipeline/pipeline.cpp | 2 -- src/mongo/db/pipeline/process_interface_standalone.cpp | 2 -- src/mongo/db/pipeline/process_interface_standalone.h | 1 - src/mongo/db/pipeline/stub_mongo_process_interface.h | 4 ---- 9 files changed, 2 insertions(+), 47 deletions(-) (limited to 'src/mongo') diff --git a/src/mongo/db/pipeline/document_source_exchange_test.cpp b/src/mongo/db/pipeline/document_source_exchange_test.cpp index 38145832b22..ff517ad4f9c 100644 --- a/src/mongo/db/pipeline/document_source_exchange_test.cpp +++ b/src/mongo/db/pipeline/document_source_exchange_test.cpp @@ -47,17 +47,6 @@ namespace mongo { -/** - * An implementation of the MongoProcessInterface that is okay with changing the OperationContext, - * but has no other parts of the interface implemented. - */ -class StubMongoProcessOkWithOpCtxChanges : public StubMongoProcessInterface { -public: - void setOperationContext(OperationContext* opCtx) final { - return; - } -}; - namespace { /** * This class is used for an Exchange consumer to temporarily relinquish control of a mutex @@ -98,7 +87,7 @@ class DocumentSourceExchangeTest : public AggregationContextFixture { protected: std::unique_ptr _executor; virtual void setUp() override { - getExpCtx()->mongoProcessInterface = std::make_shared(); + getExpCtx()->mongoProcessInterface = std::make_shared(); auto net = executor::makeNetworkInterface("ExchangeTest"); diff --git a/src/mongo/db/pipeline/document_source_facet_test.cpp b/src/mongo/db/pipeline/document_source_facet_test.cpp index 6fa1ae50e88..13b00decc38 100644 --- a/src/mongo/db/pipeline/document_source_facet_test.cpp +++ b/src/mongo/db/pipeline/document_source_facet_test.cpp @@ -541,22 +541,11 @@ TEST_F(DocumentSourceFacetTest, ShouldOptimizeInnerPipelines) { ASSERT_TRUE(dummy->isOptimized); } -/** - * An implementation of the MongoProcessInterface that is okay with changing the OperationContext, - * but has no other parts of the interface implemented. - */ -class StubMongoProcessOkWithOpCtxChanges : public StubMongoProcessInterface { -public: - void setOperationContext(OperationContext* opCtx) final { - return; - } -}; - TEST_F(DocumentSourceFacetTest, ShouldPropagateDetachingAndReattachingOfOpCtx) { auto ctx = getExpCtx(); // We're going to be changing the OperationContext, so we need to use a MongoProcessInterface // that won't throw when we do so. - ctx->mongoProcessInterface = std::make_unique(); + ctx->mongoProcessInterface = std::make_unique(); auto firstDummy = DocumentSourcePassthrough::create(); auto firstPipeline = unittest::assertGet(Pipeline::createFacetPipeline({firstDummy}, ctx)); diff --git a/src/mongo/db/pipeline/document_source_out.cpp b/src/mongo/db/pipeline/document_source_out.cpp index c0aade5b099..b5c1a0e3e9a 100644 --- a/src/mongo/db/pipeline/document_source_out.cpp +++ b/src/mongo/db/pipeline/document_source_out.cpp @@ -72,11 +72,6 @@ DocumentSourceOut::~DocumentSourceOut() { DocumentSourceWriteBlock writeBlock(cleanupOpCtx.get()); - // Reset the operation context back to original once dropCollection is done. - ON_BLOCK_EXIT( - [this] { pExpCtx->mongoProcessInterface->setOperationContext(pExpCtx->opCtx); }); - - pExpCtx->mongoProcessInterface->setOperationContext(cleanupOpCtx.get()); pExpCtx->mongoProcessInterface->dropCollection(cleanupOpCtx.get(), _tempNs); }); } diff --git a/src/mongo/db/pipeline/mongo_process_interface.h b/src/mongo/db/pipeline/mongo_process_interface.h index 4608a2da360..ff81cc88040 100644 --- a/src/mongo/db/pipeline/mongo_process_interface.h +++ b/src/mongo/db/pipeline/mongo_process_interface.h @@ -124,13 +124,6 @@ public: virtual ~MongoProcessInterface(){}; - /** - * Sets the OperationContext of the DBDirectClient used by mongo process interface functions. - * This method must be called after updating the 'opCtx' member of the ExpressionContext - * associated with the document source. - */ - virtual void setOperationContext(OperationContext* opCtx) = 0; - /** * Creates a new TransactionHistoryIterator object. Only applicable in processes which support * locally traversing the oplog. diff --git a/src/mongo/db/pipeline/mongos_process_interface.h b/src/mongo/db/pipeline/mongos_process_interface.h index 654043983f7..7276de5cc84 100644 --- a/src/mongo/db/pipeline/mongos_process_interface.h +++ b/src/mongo/db/pipeline/mongos_process_interface.h @@ -49,8 +49,6 @@ public: virtual ~MongoSInterface() = default; - void setOperationContext(OperationContext* opCtx) final {} - boost::optional lookupSingleDocument( const boost::intrusive_ptr& expCtx, const NamespaceString& nss, diff --git a/src/mongo/db/pipeline/pipeline.cpp b/src/mongo/db/pipeline/pipeline.cpp index 4dc6eb2a972..bbe003e036e 100644 --- a/src/mongo/db/pipeline/pipeline.cpp +++ b/src/mongo/db/pipeline/pipeline.cpp @@ -320,7 +320,6 @@ bool Pipeline::aggHasWriteStage(const BSONObj& cmd) { void Pipeline::detachFromOperationContext() { pCtx->opCtx = nullptr; - pCtx->mongoProcessInterface->setOperationContext(nullptr); for (auto&& source : _sources) { source->detachFromOperationContext(); @@ -329,7 +328,6 @@ void Pipeline::detachFromOperationContext() { void Pipeline::reattachToOperationContext(OperationContext* opCtx) { pCtx->opCtx = opCtx; - pCtx->mongoProcessInterface->setOperationContext(opCtx); for (auto&& source : _sources) { source->reattachToOperationContext(opCtx); diff --git a/src/mongo/db/pipeline/process_interface_standalone.cpp b/src/mongo/db/pipeline/process_interface_standalone.cpp index 3591e968a4f..94e00b7955a 100644 --- a/src/mongo/db/pipeline/process_interface_standalone.cpp +++ b/src/mongo/db/pipeline/process_interface_standalone.cpp @@ -154,8 +154,6 @@ bool supportsUniqueKey(const boost::intrusive_ptr& expCtx, MongoInterfaceStandalone::MongoInterfaceStandalone(OperationContext* opCtx) {} -void MongoInterfaceStandalone::setOperationContext(OperationContext* opCtx) {} - std::unique_ptr MongoInterfaceStandalone::createTransactionHistoryIterator(repl::OpTime time) const { bool permitYield = true; diff --git a/src/mongo/db/pipeline/process_interface_standalone.h b/src/mongo/db/pipeline/process_interface_standalone.h index e2f10f37545..55c75cd893d 100644 --- a/src/mongo/db/pipeline/process_interface_standalone.h +++ b/src/mongo/db/pipeline/process_interface_standalone.h @@ -54,7 +54,6 @@ public: virtual ~MongoInterfaceStandalone() = default; - void setOperationContext(OperationContext* opCtx) final; std::unique_ptr createTransactionHistoryIterator( repl::OpTime time) const final; diff --git a/src/mongo/db/pipeline/stub_mongo_process_interface.h b/src/mongo/db/pipeline/stub_mongo_process_interface.h index c34d3c6a489..8af7f047458 100644 --- a/src/mongo/db/pipeline/stub_mongo_process_interface.h +++ b/src/mongo/db/pipeline/stub_mongo_process_interface.h @@ -46,10 +46,6 @@ class StubMongoProcessInterface : public MongoProcessInterface { public: virtual ~StubMongoProcessInterface() = default; - void setOperationContext(OperationContext* opCtx) override { - MONGO_UNREACHABLE; - } - std::unique_ptr createTransactionHistoryIterator( repl::OpTime time) const override { MONGO_UNREACHABLE; -- cgit v1.2.1