[SERVER-54773] $_internalUnpackBucket shouldn't forward deps to the next stage. Created: 24/Feb/21  Updated: 24/Feb/21  Resolved: 24/Feb/21

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

Type: Bug Priority: Major - P3
Reporter: Eric Cox (Inactive) Assignee: Eric Cox (Inactive)
Resolution: Won't Fix Votes: 0
Labels: qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Sprint: Query Execution 2021-03-08
Participants:

 Description   

In SERVER-54221 we are using DepsTracker::State::SEE_NEXT for the getDependency() overload in DocumentSourceInternalUnpackBucket. This causes a problem when a few different kinds of queries are run against the time-series collection.

coll.find({}, {x: 1}).sort({x: 1})

Will fail because the the deps for $_internalUnpackBucket will inherit from the $project directly after $_internalUnpackBucket and cause the find layer absorb the $project and execute with a PROJECT_SIMPLE stage with just an inclusion projection on field x. This will mangle the bucket and $_internalUnpackBucket will fail.

"stages" : [
		{
			"$cursor" : {
				"queryPlanner" : {
					"namespace" : "test.system.buckets.timeseries_bucket_limit_count_1",
					"indexFilterSet" : false,
					"parsedQuery" : {
					},
					"queryHash" : "0E456FB4",
					"planCacheKey" : "0E456FB4",
					"maxIndexedOrSolutionsReached" : false,
					"maxIndexedAndSolutionsReached" : false,
					"maxScansToExplodeReached" : false,
					"winningPlan" : {
						"stage" : "PROJECTION_SIMPLE",
						"transformBy" : {
							"_id" : 1,
							"x" : 1
						},
						"inputStage" : {
							"stage" : "COLLSCAN",
							"direction" : "forward"
						}
					},
					"rejectedPlans" : [ ]
				}
			}
		},
		{
			"$_internalUnpackBucket" : {
				"include" : [
					"_id",
					"x"
				],
				"timeField" : "time"
			}
		},
		{
			"$project" : {
				"_id" : true,
				"x" : true
			}
		},
		{
			"$sort" : {
				"sortKey" : {
					"_id" : 1
				}
			}
		},
		{
			"$project" : {
				"_id" : true,
				"x" : true
			}
		}

A fix for this is to use NOT_SUPPORTED for the deps tracker in $_internalUnpackBucket.


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