Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54773

$_internalUnpackBucket shouldn't forward deps to the next stage.

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • ALL
    • Query Execution 2021-03-08

      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.

            Assignee:
            eric.cox@mongodb.com Eric Cox (Inactive)
            Reporter:
            eric.cox@mongodb.com Eric Cox (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: