Skip to content

DOCS-13479 Add note for out and merge behavior on RS #6065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion source/reference/operator/aggregation/merge.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,28 @@ Definition

- Can output to a collection in the same or different database.

- Starting in MongoDB 4.4, :pipeline:`$merge` can output to the
- Starting in MongoDB 4.4:

- :pipeline:`$merge` can output to the
same collection that is being aggregated. For more
information, see :ref:`merge-behavior-same-collection`.

- Pipelines with the :pipeline:`$merge` stage can run on
replica set secondary nodes if all the nodes in cluster have
:ref:`featureCompatibilityVersion <view-fcv>` set
to ``4.4`` or higher and the :doc:`/core/read-preference`
allows secondary reads.

- Read operations of the :pipeline:`$merge` statement are sent to
secondary nodes, while the write operations occur only on the
primary node.

- Not all driver versions support targeting of :pipeline:`$merge`
operations to replica set secondary nodes. Check your
:driver:`driver </>` documentation to see when your driver added
support for :pipeline:`$merge` read operations running on
secondary nodes.

- Creates a new collection if the output collection does not already
exist.

Expand Down
18 changes: 18 additions & 0 deletions source/reference/operator/aggregation/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ Comparison with ``$merge``
Behaviors
---------

$out Read Operations Run on Secondary Replica Set Members
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Starting in MongoDB 4.4, :pipeline:`$out` can run on
replica set secondary nodes if all the nodes in
cluster have :ref:`featureCompatibilityVersion <view-fcv>` set
to ``4.4`` or higher and the :doc:`/core/read-preference` is set to
secondary.

Read operations of the :pipeline:`$out` statement occur on the
secondary nodes, while the write operations occur only on the
primary nodes.

Not all driver versions support targeting of :pipeline:`$out`
operations to replica set secondary nodes. Check your
:driver:`driver </>` documentation to see when your driver added
support for :pipeline:`$out` running on a secondary.

Create New Collection
~~~~~~~~~~~~~~~~~~~~~

Expand Down
30 changes: 27 additions & 3 deletions source/release-notes/4.4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,19 @@ General Aggregation Improvements
``$out``
````````

Starting in MongoDB 4.4, :pipeline:`$out` can output to a collection in
a different database. In earlier versions, :pipeline:`$out` can output
to a collection to the same database where the aggregation is run.
Starting in MongoDB 4.4:

- :pipeline:`$out` can output to a collection in
a different database. In earlier versions, :pipeline:`$out` can only
output to a collection in the same database database where the
aggregation is run.

- :pipeline:`$out` can only run on replica set secondary nodes if
all the nodes in cluster have
:ref:`featureCompatibilityVersion <view-fcv>` set to ``4.4`` or
higher and the :doc:`/core/read-preference` allows secondary reads.
Check your :driver:`driver </>` documentation to see when your
driver added support.

``$indexStats``
```````````````
Expand Down Expand Up @@ -417,6 +427,20 @@ Starting in MongoDB 4.4 (also available starting in 4.2.4),
``$merge``
``````````

Starting in MongoDB 4.4:

- :pipeline:`$merge` can output to a collection in
a different database. In earlier versions, :pipeline:`$merge` can
only output to a collection in the same database where the aggregation
is run.

- :pipeline:`$merge` can only run on replica set secondary nodes if
all the nodes in cluster have
:ref:`featureCompatibilityVersion <view-fcv>` set to ``4.4`` or
higher and the :doc:`/core/read-preference` allows secondary reads.
Check your :driver:`driver </>` documentation to see
when your driver added support.

.. include:: /includes/fact-merge-same-collection-behavior.rst

.. include:: /includes/fact-merge-same-collection-warning.rst
Expand Down