[SERVER-41053] Update pipelines should not create a service context Created: 08/May/19  Updated: 29/Oct/23  Resolved: 09/May/19

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 4.1.12

Type: Bug Priority: Major - P3
Reporter: Ian Boros Assignee: Ian Boros
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2019-05-20
Participants:

 Description   

By calling DocumentSourceMock::create() from the update pipeline executor, an ExpressionContextForTest is created, which creates a full service context. This code should use a different constructor for DocumentSourceMock.



 Comments   
Comment by Githook User [ 09/May/19 ]

Author:

{'name': 'Ian Boros', 'username': 'puppyofkosh', 'email': 'puppyofkosh@gmail.com'}

Message: SERVER-41053 Don't create ServiceContexts while doing updates

This commit also renames DocumentSourceMock::create to DocumentSourceMock::createForTest.
Branch: master
https://github.com/mongodb/mongo/commit/bf47260ea0cbc58d3744d8964b2eb036b9a1a19e

Comment by Githook User [ 09/May/19 ]

Author:

{'email': 'puppyofkosh@gmail.com', 'name': 'Ian Boros', 'username': 'puppyofkosh'}

Message: SERVER-41053 change DocumentSourceMock::create to DocumentSourceMock::createForTest
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/5911669bd5005910db80366aaad617d51da02f3e

Comment by Ian Boros [ 08/May/19 ]

I think this is all we need to fix the issue:

 
diff --git a/src/mongo/db/update/pipeline_executor.cpp b/src/mongo/db/update/pipeline_executor.cpp
index f2e66da44b..1e1212d9dd 100644
--- a/src/mongo/db/update/pipeline_executor.cpp
+++ b/src/mongo/db/update/pipeline_executor.cpp
@@ -71,7 +71,8 @@ PipelineExecutor::PipelineExecutor(const boost::intrusive_ptr<ExpressionContext>
         invariant(!stageConstraints.isIndependentOfAnyCollection);
     }
 
-    _pipeline->addInitialSource(DocumentSourceMock::create());
+    boost::intrusive_ptr<DocumentSourceMock> mock(new DocumentSourceMock({}, expCtx));
+    _pipeline->addInitialSource(std::move(mock));
 }
 
 UpdateExecutor::ApplyResult PipelineExecutor::applyUpdate(ApplyParams applyParams) const {
 

 

Comment by Ian Boros [ 08/May/19 ]

As part of this, we should consider renaming DocumentSourceMock::create() to DocumentSourceMock::createForTest().

Generated at Thu Feb 08 04:56:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.