- 
    Type:
Bug
 - 
    Resolution: Done
 - 
    Priority:
Major - P3
 - 
    Affects Version/s: 3.1.4
 - 
    Component/s: Aggregation Framework
 
- 
        Fully Compatible
 - 
        ALL
 - 
        
 - 
        Query 2017-07-10, Query 2017-07-31, Query 2017-08-21
 - 
        None
 
- 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 
The fix implemented on SERVER-7656 doesn't fully address the issue, because it only works with an exact $match on the full shard key.  However, it is possible for an aggregation to be directed to a single shard even without this.  For example:
- a range query that is wholly contained within a single chunk
 - a prefix match on the shard key, where the trailing fields are wholly contained within a single chunk
 
This means that an aggregation may be perfectly targeted to a single shard, but will not be passed through to that shard.
Case #2 is particularly problematic when _id is appended to the shard key (to guarantee granularity), but is never actually used in queries/aggs (and the rest of the shard key is usually/often enough to target just one shard).
- depends on
 - 
                    
SERVER-27937 pull apart the AsyncResultsMerger logic into (1) establishing the cursors (2) sending the getMore's
-         
 - Closed
 
 -         
 
- is duplicated by
 - 
                    
SERVER-23330 Optimize aggregation on sharded setup if first stage is exact match on shard key with $in
-         
 - Closed
 
 -         
 - 
                    
SERVER-30216 Rename AggregationRequest::isFromRouter() to better represent actual meaning
-         
 - Closed
 
 -         
 
- is related to
 - 
                    
SERVER-22671 Implement serverStatus section with active migrations
-         
 - Closed
 
 -         
 
- related to
 - 
                    
SERVER-30899 Adapting meaning of 'fromRouter' causes problems in mixed version clusters
-         
 - Closed
 
 -         
 - 
                    
SERVER-23955 Return what host the Shard::runCommand actually ran on
-         
 - Backlog
 
 -         
 - 
                    
SERVER-27283 Sharded aggregations that need merging should only consider for merging the shards that have documents to contribute
-         
 - Backlog
 
 -         
 - 
                    
SERVER-7656 Optimize aggregation on sharded setup if first stage is exact match on shard key
-         
 - Closed
 
 -         
 - 
                    
SERVER-22760 Sharded aggregation pipelines which involve taking a simple union should merge on mongos
-         
 - Closed
 
 -