[SERVER-31406] Running aggregate cmd with explain:false is the same as cursor:{} Created: 05/Oct/17  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Aggregation Framework, Querying
Affects Version/s: 3.5.12
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Operating System: ALL
Steps To Reproduce:

In the MongoDB shell:

test> db.version()
3.5.12-380-g168f195001
test> db.test.insert([{x:1},{x:2},{x:3}]);

Try aggregating without the cursor document:

test> db.runCommand({aggregate: "test", pipeline: []})
{
	"operationTime" : Timestamp(1507216222, 1),
	"ok" : 0,
	"errmsg" : "The 'cursor' option is required, except for aggregate with the explain argument",
	"code" : 9,
	"codeName" : "FailedToParse"
}

Now with the cursor document:

test> db.runCommand({aggregate: "test", pipeline: [], cursor:{}})
{
	"cursor" : {
		"firstBatch" : [
			{
				"_id" : ObjectId("59d64b3c374bbed61ea8ba4a"),
				"x" : 1
			},
			{
				"_id" : ObjectId("59d64b3c374bbed61ea8ba4b"),
				"x" : 2
			},
			{
				"_id" : ObjectId("59d64b3c374bbed61ea8ba4c"),
				"x" : 3
			}
		],
		"id" : NumberLong(0),
		"ns" : "test.test"
	},
	"ok" : 1,
	"operationTime" : Timestamp(1507216252, 1)
}

But it behaves the same as passing explain:false

test> db.runCommand({aggregate: "test", pipeline: [], explain:false})
{
	"cursor" : {
		"firstBatch" : [
			{
				"_id" : ObjectId("59d64b3c374bbed61ea8ba4a"),
				"x" : 1
			},
			{
				"_id" : ObjectId("59d64b3c374bbed61ea8ba4b"),
				"x" : 2
			},
			{
				"_id" : ObjectId("59d64b3c374bbed61ea8ba4c"),
				"x" : 3
			}
		],
		"id" : NumberLong(0),
		"ns" : "test.test"
	},
	"ok" : 1,
	"operationTime" : Timestamp(1507216292, 1)
}

Participants:

 Description   

When running aggregate on MongoDB 3.5.12, it seems like the option explain:false has the same effect as passing an empty cursor document. Per SERVER-24623 the command should be required to pass explain:true or an empty cursor document.


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