-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Execution
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Pipeline::detachFromOperationContext() and Pipeline::reattachToOperationContext() is a constant source of bugs. OperationContext propagation to sub-pipelines (and stages) is unnecessarily complex and error-prone and it should only be relevant to the execution pipeline (exec::agg::Pipeline). One solution is to remove OperationContext from ExpressionContext and make it available only to the execution pipeline.
An alternative split (as suggested by justin.seyster@mongodb.com) would be to
... split ExpressionContext's fields into query-global state (things that should always be identical for all the ExpressionContexts created by a query) and sub-query state (things that might be different between a pipeline's ExpressionContext and the cloned ExpressionContext that gets created for a subordinate pipeline in a $lookup, $union, or similar). The global fields could all be moved into a dedicated object that each ExpressionContext object would hold a shared_ptr to. All the ExpressionContexts in a query would all point to the same global context, meaning that detach/reattach would only need to update that one global context.
Independently from which alternative will be chosen, we need to remove detachFromOperationContext() and reattachToOperationContext() from the QO Pipeline and DocumentSource classes as a part of this ticket.
This ticket is related to SPM-4106, but can be processed independently and is out the project's scope.
- related to
-
SERVER-109935 Auto-dispose QE aggregation stages in stage destructor
-
- Needs Scheduling
-