- 
    Type:Bug 
- 
    Resolution: Fixed
- 
    Priority:Major - P3 
- 
    Affects Version/s: None
- 
    Component/s: Aggregation Framework
- 
    None
- 
        Fully Compatible
- 
        ALL
- 
        v4.2
- 
        Query 2020-04-20, Query 2020-05-04
- 
        50
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
In SERVER-43860, we fixed the behaviour of $merge in the case where we have {whenMatched: pipeline} and {whenNotMatched: insert}. For upgrade/downgrade purposes, we made this new behaviour conditional on the presence of a flag, useNewUpsert, which is set by 4.4 mongoS on aggregations that are sent to the shards. We then backported this fix to 4.2.2.
However, in cases where a $merge is sent to a shard as part of a $mergeCursors pipeline, the 'useNewUpsert' flag is not set on the command. In these scenarios, the old incorrect behaviour is still observed.
- is related to
- 
                    SERVER-43860 Pipeline style update in $merge can produce unexpected result -         
- Closed
 
-