-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Minor - P4
-
Affects Version/s: 4.1.10
-
Component/s: Querying
-
Fully Compatible
-
Query 2020-02-24, Query 2020-03-09
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
ExpressionContextForTest owns a service context. DocumentSourceMock will create an ExpressionContextForTest in its create() methods. This means that each time a DocumentSourceMock is created, we go through all of the work of creating an entire service context.
At the same time, the AggregationContextFixture inherits from ServiceContextFixture, which already makes a global ServiceContext available. This means that many of the aggregation stage unit tests actually have (at least) two service contexts: one globally and another as part of the ExpressionContextForTest.
While there is no immediate bug here, this was responsible for:
And also caused a lot of confusion while doing investigations for
The ownership hierarchy should probably changed so that there's just one ServiceContext for the lifetime of the test which is threaded through ExpressionContextForTest.