Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-38360

Disallow pipelines which read from the same namespace that they write to



    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.9
    • Component/s: Aggregation Framework
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Epic Link:
    • Sprint:
      Query 2018-12-31, Query 2019-01-14, Query 2019-01-28, Query 2019-02-11, Query 2019-02-25


      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.


          Issue Links



              • Votes:
                1 Vote for this issue
                7 Start watching this issue


                • Created: