[SERVER-14628] Aggregation explain "cursor" field truncated Created: 21/Jul/14  Updated: 14/Apr/16  Resolved: 26/Jan/15

Status: Closed
Project: Core Server
Component/s: Aggregation Framework, Diagnostics, Querying
Affects Version/s: 2.6.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: David Storch
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-15958 The "isMultiKey" value is not correct... Closed
Related
related to SERVER-14610 Detailed explain does not list reject... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

Affects 2.6.x.

When an aggregation explain is run on a cached plan, the server outputs a truncated value for the "cursor" field.

> db.foo.drop()
true
> db.foo.ensureIndex({a:1})
{
	"createdCollectionAutomatically" : true,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
> db.foo.ensureIndex({b:1})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 2,
	"numIndexesAfter" : 3,
	"ok" : 1
}
> db.foo.insert({a:1,b:2})
WriteResult({ "nInserted" : 1 })
> db.foo.insert({a:1,b:2})
WriteResult({ "nInserted" : 1 })
> db.foo.insert({a:1,b:2})
WriteResult({ "nInserted" : 1 })
> db.foo.aggregate([{$match: {a:1,b:1}}]) // Caches plan.
> db.foo.aggregate([{$match: {a:1,b:1}}],{explain:true})
{
	"stages" : [
		{
			"$cursor" : {
				"query" : {
					"a" : 1,
					"b" : 1
				},
				"plan" : {
					"cursor" : "BtreeCursor ", // INCORRECT
					"isMultiKey" : false,
					"scanAndOrder" : false,
					"indexBounds" : {
						"b" : [
							[
								1,
								1
							]
						]
					},
					"allPlans" : [
						{
							"cursor" : "BtreeCursor ", // INCORRECT
							"isMultiKey" : false,
							"scanAndOrder" : false,
							"indexBounds" : {
								"b" : [
									[
										1,
										1
									]
								]
							}
						}
					]
				}
			}
		}
	],
	"ok" : 1
}
>

Aggregation queries with only one solution are affected, as well.

> db.foo.aggregate([{$match: {a:1}}],{explain:true})
{
	"stages" : [
		{
			"$cursor" : {
				"query" : {
					"a" : 1
				},
				"plan" : {
					"cursor" : "BtreeCursor ", // INCORRECT
					"isMultiKey" : false,
					"scanAndOrder" : false,
					"indexBounds" : {
						"a" : [
							[
								1,
								1
							]
						]
					},
					"allPlans" : [
						{
							"cursor" : "BtreeCursor ", // INCORRECT
							"isMultiKey" : false,
							"scanAndOrder" : false,
							"indexBounds" : {
								"a" : [
									[
										1,
										1
									]
								]
							}
						}
					]
				}
			}
		}
	],
	"ok" : 1
}
>



 Comments   
Comment by David Storch [ 26/Jan/15 ]

This has already been fixed under SERVER-15958 for version 2.6.6, as this issue has the same root cause. The fix is in commit 671e340cf5. Resolving as a duplicate.

Generated at Thu Feb 08 03:35:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.