[SERVER-34902] view definitions should *not* allow $out as a stage Created: 08/May/18  Updated: 29/Oct/23  Resolved: 12/Jun/18

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

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Sam Mercier
Resolution: Fixed Votes: 0
Labels: neweng, read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Documented
is documented by DOCS-11807 Docs for SERVER-34902: view definitio... Closed
Gantt Dependency
has to be done before SERVER-35419 Make diskRequirement in StageConstrai... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Backport Requested:
v4.0
Sprint: Query 2018-06-18
Participants:

 Description   

We seem to allow $out stage as part of view definition.

This is problematic for several reasons. One is that trying to append any stages (i.e. doing anything other than a simple find() on this view) will fail. The other is that running find on this view will blow away whatever is in the collection named in "$out" which is not an obvious outcome and unlikely to have a valid use case for it.



 Comments   
Comment by Ian Boros [ 22/Jun/18 ]

The patch for this ticket was written under the assumption that the issue with $out being inside a view definition is that it's possible to perform a write while reading from a "read-only" view definition. The fix bans any stage which writes permanent data to disk from being a top-level stage in a view pipeline ("top-level" meaning not part of a sub-pipeline).

After talking to Asya, we now understand that the actual problem with allowing $out in a view pipeline is that it doesn't return any documents and must be the last stage. This means that doing operations (other than a simple find()) on a view pipeline with an $out will fail.

If in the future we ever add stages which are similar to $out in that they don't return any documents (and must be the last stage), we'll likely have to come back to this.

Comment by Githook User [ 12/Jun/18 ]

Author:

{'username': 'samontea', 'name': 'samontea', 'email': 'merciers.merciers@gmail.com'}

Message: SERVER-34902 disallow $out in view pipeline
Branch: master
https://github.com/mongodb/mongo/commit/5c02fd1ae02a5243338cc36bf44cf4c8574edc4e

Comment by Asya Kamsky [ 11/May/18 ]

After implementation we should decide if it should be backported.

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