[SERVER-38360] Disallow pipelines which read from the same namespace that they write to Created: 03/Dec/18  Updated: 29/Oct/23  Resolved: 14/Feb/19

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 4.1.9

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: Charlie Swanson
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-39394 Views collation check should traverse... Closed
Documented
is documented by DOCS-12484 Docs for SERVER-38360: Disallow pipel... Closed
Related
related to SERVER-42137 Allow aggregation $merge stage to wri... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 2018-12-31, Query 2019-01-14, Query 2019-01-28, Query 2019-02-11, Query 2019-02-25
Participants:

 Description   

SERVER-37378 tracked 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.



 Comments   
Comment by Githook User [ 14/Feb/19 ]

Author:

{'name': 'Charlie Swanson', 'email': 'charlie.swanson@mongodb.com', 'username': 'cswanson310'}

Message: SERVER-38360 Prevent $out writing to ns read from in the same pipeline

This restriction only applies to $out with modes "insertDocuments" and
"replaceDocuments".
Branch: master
https://github.com/mongodb/mongo/commit/f1da8170c1c568762b29e44910afbcc6f01a644f

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