[SERVER-33718] Explain does not produce a plan for mongoS-only aggregation pipelines Created: 07/Mar/18  Updated: 29/Oct/23  Resolved: 24/Mar/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.6.0, 3.7.1
Fix Version/s: 3.7.4

Type: Bug Priority: Major - P3
Reporter: Bernard Gorman Assignee: Bernard Gorman
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Sprint: Query 2018-03-12, Query 2018-03-26, Query 2018-04-09
Participants:

 Description   

When an explain is run on a pipeline that must execute entirely on mongoS, the result is an empty cursor batch rather than an explain plan:

mongos> db.adminCommand({explain: {aggregate: 1, pipeline: [{$listLocalSessions:
{}}], cursor: {}}})
{
	"cursor" : {
		"firstBatch" : [ ],
		"id" : NumberLong(0),
		"ns" : "admin.$cmd.aggregate"
	},
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1519932263, 2),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1519932263, 2)
}

Instead, the output should be an explain plan indicating that this is a mongoS-only pipeline:

mongos> db.adminCommand({explain: {aggregate: 1, pipeline: [{$listLocalSessions: {}}], cursor: {}}})
{
	"splitPipeline" : null,
	"mongos" : {
		"host" : "Bernards-MacBook-Pro-2.local:27017",
		"stages" : [
			{
				"$listLocalSessions" : {
					"allUsers" : false,
					"users" : [
						{
							"user" : "",
							"db" : ""
						}
					]
				}
			}
		]
	},
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1520430504, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1520430504, 1)
}



 Comments   
Comment by Githook User [ 24/Mar/18 ]

Author:

{'email': 'bernard.gorman@gmail.com', 'name': 'Bernard Gorman', 'username': 'gormanb'}

Message: SERVER-33718 Explain does not produce a plan for mongoS-only aggregation pipelines
Branch: master
https://github.com/mongodb/mongo/commit/83031a24b9e7bcc55ead1b838fba1e0a11503409

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