[SERVER-37821] Modify explain output for aggregations against mongos which target unsharded collections Created: 30/Oct/18  Updated: 06/Dec/22  Resolved: 26/May/20

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Jeffrey Yemin Assignee: Backlog - Query Team (Inactive)
Resolution: Won't Fix Votes: 0
Labels: neweng, query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by JAVA-2993 Re enable Test: AggregateToCollection... Closed
Assigned Teams:
Query
Operating System: ALL
Steps To Reproduce:

On a sharded cluster

  1. Create unsharded collection
  2. Execute explain of an aggregate command with a single $out stage (defaulting to replace existing collection)
    Expected results:

stages array is at the top level of the explain output

Actual results

stages array is nested within shards.<shard name>

Sample output:

{
  "splitPipeline" : null,
  "shards" : {
    "sh02" : {
      "host" : "localhost:27218",
      "stages" : [{
          "$cursor" : {
            "query" : { },
            "queryPlanner" : {
              "plannerVersion" : 1,
              "namespace" : "JavaDriverTest.com.mongodb.operation.AggregateToCollectionOperationSpecification",
              "indexFilterSet" : false,
              "parsedQuery" : { },
              "queryHash" : "8B3D4AB8",
              "winningPlan" : {
                "stage" : "FETCH",
                "inputStage" : {
                  "stage" : "IXSCAN",
                  "keyPattern" : {
                    "a" : 1
                  },
                  "indexName" : "a_1",
                  "isMultiKey" : false,
                  "multiKeyPaths" : {
                    "a" : []
                  },
                  "isUnique" : false,
                  "isSparse" : false,
                  "isPartial" : false,
                  "indexVersion" : 2,
                  "direction" : "forward",
                  "indexBounds" : {
                    "a" : ["[MinKey, MaxKey]"]
                  }
                }
              },
              "rejectedPlans" : []
            }
          }
        }, {
          "$out" : {
            "to" : "outputCollection",
            "db" : "JavaDriverTest",
            "mode" : "replaceCollection",
            "uniqueKey" : {
              "_id" : 1
            }
          }
        }]
    }
  },
  "ok" : 1.0,
   ...
}

Participants:

 Description   

On master with a sharded cluster but an unsharded collection, the stages array in the explain output of an aggregate command with hint and $out is nested in shards.<shard name>. This is different than 4.0 and earlier branches, in which the stages array is at the top level.



 Comments   
Comment by Nicholas Zolnierz [ 31/Oct/18 ]

Putting into Needs Scheduling as I've verified this is indeed a regression. Allowing the $out to passthrough from mongos here fixes the explain output, but would cause undesirable side effects with respect to the unique key validation.

Comment by Nicholas Zolnierz [ 30/Oct/18 ]

Good catch jeff.yemin. I was able to reproduce this, with or without the hint. I believe it may be related to forcing a full parse on mongos even for unsharded collections from this commit.

Comment by Charlie Swanson [ 30/Oct/18 ]

Assigning to nicholas.zolnierz to take a look and see if we know when/why this changed.

Generated at Thu Feb 08 04:47:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.