-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
None
-
3
-
TBD
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When creating a ChangeStream object from an ExpressionContext using the static function ChangeStream::createFromExpressionContext(), it forwards the NamespaceString that's currently stored in the ExpressionContext to the ChangeStream object.
This is problematic for multiple reasons:
- The NamespaceString for whole cluster change streams is stored as an admin namespace in the ExpressionContext, but is required to be an empty string (or empty boost::optional<NamespaceString> in the ChangeStream object.
- The NamespaceString for database level change streams is stored as an aggregate command namespace (e.g. dbname.$cmd.aggregate) in the ExpressionContext, but is required to be a single database name in the ChangeStream object.
We are currently not performing such translation inside ChangeStream::createFromExpressionContext(), so the function won't work for whole cluster and database level change streams right now. This is not an issue at the moment because the function is currently only used in test code.
If we add such translation in the function, another problem will be that it will lead to a different Namespace value being stored in the ChangeStream object than in the ExpressionContext.
For example:
// database level change stream: auto nss = expCtx->getNamespaceString(); // e.g. "dbName.$cmd.aggregate" auto cs = ChangeStream::createFromExpressionContext(expCtx); cs->getNamespace(); // "dbName" // cluster level change stream: auto nss = expCtx->getNamespaceString(); // e.g. "admin" auto cs = ChangeStream::createFromExpressionContext(expCtx); cs->getNamespace(); // ""
We should thus clarify if we want to perform this translation at all.
If yes, we will need to fix the createFromExpressionContext() method for whole cluster and database level change streams.
If not, we will need to change the constructor and unit tests for ChangeStream.