-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Labels:None
Description
Description:
$out with the new modes "insertDocuments" and "replaceDocuments" cannot write to a collection which is being read to by the aggregation or any $lookup or $graphLookup within the aggregation.
Engineering Ticket Description:
SERVER-37378tracked the work to prevent the new "insertDocuments" and "replaceDocuments" $out modes from writing to the same namespace as the source of the aggregation. The existing "replaceCollection" mode is exempted from this restriction because this mode will write results to a temporary collection first. This means the intermediate results are not readable, and so this mode doesn't risk a server-side infinite-loop.We should go one step further and prevent $out (with these new modes) from writing to the same namespace as any namespace read from in the pipeline, specifically including with a $lookup or $graphLookup.
It's unclear how we'll want to go about doing this, but the information about which namespaces are involved in the aggregation is most easily accessible from the LiteParsedPipeline. Unfortunately we don't have access to a LiteParsedPipeline at the time we are parsing an $out stage, so this check might have to live outside of DocumentSourceOut itself.
Scope of changes
Impact to Other Docs
MVP (Work and Date)
Resources (Scope or Design Docs, Invision, etc.)
- documents
-
SERVER-38360 Disallow pipelines which read from the same namespace that they write to
- Closed