Skip to content

Commit 1aec060

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCS-16771-read-pref-update (#8433) (#8462)
* DOCS-16771-read-pref-update * DOCS-16771-read-pref-update * DOCS-16771-read-pref-update * DOCS-16771-read-pref-update * DOCS-16771-read-pref-update * DOCS-16771-read-pref-update * DOCS-16771-read-pref-update * DOCS-16771-read-pref-update * DOCS-16771-read-pref-update * DOCS-16771-read-pref-update * DOCS-16771-read-pref-update --------- Co-authored-by: jason-price-mongodb <[email protected]>
1 parent 3cb86ae commit 1aec060

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

source/core/read-preference.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,7 @@ Read Preference and Transactions
228228
Additional Considerations
229229
-------------------------
230230

231-
For :doc:`aggregation pipeline </core/aggregation-pipeline>`
232-
operations that include the :pipeline:`$out` or :pipeline:`$merge`
233-
stages, the pipeline runs on the :term:`primary` member regardless of
234-
read preference setting.
231+
.. include:: /includes/merge-and-read-preference.rst
235232

236233
For :dbcommand:`mapReduce` operations, only "inline"
237234
:dbcommand:`mapReduce` operations that do not write data support read
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Consider the following points when using :pipeline:`$merge` or
2+
:pipeline:`$out` stages in an :ref:`aggregation pipeline
3+
<aggregation-pipeline>`:
4+
5+
- Starting in MongoDB 5.0, pipelines with a ``$merge`` stage can run on
6+
replica set :term:`secondary` nodes if all the nodes in the cluster
7+
have the :ref:`featureCompatibilityVersion <view-fcv>` set to ``5.0``
8+
or higher and the :ref:`read preference <read-preference>`
9+
allows secondary reads.
10+
11+
- ``$merge`` and ``$out`` stages run on secondary nodes, but write
12+
operations are sent to the :term:`primary` node.
13+
14+
- Not all driver versions support ``$merge`` operations sent to
15+
the secondary nodes. For details, see the :driver:`driver </>`
16+
documentation.
17+
18+
- In earlier MongoDB versions, pipelines with ``$out`` or ``$merge``
19+
stages always run on the primary node and read preference isn't
20+
considered.

source/reference/operator/aggregation/merge.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,7 @@ Definition
4040
- Can output to the same collection that is being aggregated. For more
4141
information, see :ref:`merge-behavior-same-collection`.
4242

43-
- Pipelines with the :pipeline:`$merge` stage can run on
44-
replica set secondary nodes if all the nodes in cluster have
45-
:ref:`featureCompatibilityVersion <view-fcv>` set
46-
to ``5.0`` or higher and the :doc:`/core/read-preference`
47-
allows secondary reads.
48-
49-
- Read operations of the :pipeline:`$merge` statement are sent to
50-
secondary nodes, while the write operations occur only on the
51-
primary node.
52-
53-
- Not all driver versions support targeting of :pipeline:`$merge`
54-
operations to replica set secondary nodes. Check your
55-
:driver:`driver </>` documentation to see when your driver added support
56-
for :pipeline:`$merge` read operations running on secondary nodes.
43+
- .. include:: /includes/merge-and-read-preference.rst
5744

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

0 commit comments

Comments
 (0)