-
Type: Task
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Labels:
$out notes:
Starting in MongoDB 4.4, $out can run on replica set secondary nodes if all the nodes in cluster have featureCompatibilityVersion set to 4.4 or higher and the Read Preference is set to secondary.
However Drivers made the decision to only support this feature on 5.0+ clusters. The Server Selection spec says:
For pre-5.0 servers, an aggregate command is "must-use-primary" if its
pipeline contains a write stage (e.g. ``$out``, ``$merge``); otherwise, it
is "may-use-secondary". For 5.0+ servers, secondaries can execute an
aggregate command with a write stage and all aggregate commands are
"may-use-secondary". This is discussed in more detail in
Read preferences and server selection in the CRUD spec.
DRIVERS-823 / CSHARP-3397 which implements this feature also says:
As of MongoDB 5.0, drivers can support read preferences (either explicit/per-operation or inherited) for aggregations including an $out/$merge stage. Previously, such pipelines would always require a primary.
Our documentation should note that $out on secondaries is only available for 5.0+ clusters, not 4.4+ clusters.
- related to
-
CSHARP-4290 Incorrect feature version for "AggregateOutOnSecondary"
- Closed