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

Block-enabled projection transitioning to scalar processing doesn't clean up the state

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • Fully Compatible
    • ALL
    • Hide
      db.Collection1.explain().aggregate([{ $project: { "obj.newField": "$topLevelScalar" } }, { $project: { "obj.a": 0 } }]);
      

      generates the plan

      [4] project [s14 = makeBsonObj(MakeObjSpec([obj = MakeObj([a], Open, RetInput)], [_id, obj], Closed, RetInput), null, true, s8, s13)] 
      [3] project [s13 = getField(s12, \"obj\")] 
      [3] project [s12 = makeBsonObj(MakeObjSpec([obj = MakeObj([newField = Arg(0)], Closed)], [obj], Closed), null, true, s9, s7)] 
      [3] block_to_row blocks[s3, s4, s7, s5] row[s8, s9, s10, s11] 
      [3] project [s7 = cellFoldValues_P(cellBlockGetFlatValuesBlock(s5), s5)] 
      [2] ts_bucket_to_cellblock s1 pathReqs[s3 = ProjectPath(Get(_id)/Id), s4 = ProjectPath(Get(obj)/Id), s5 = ProjectPath(Get(topLevelScalar)/Id)]
      [1] scan s1 s2 none none none none none none lowPriority [] @\"be9e4531-c681-4da5-b7db-8326db4ad559\" true false
      

      where makeBsonObj uses s7 instead of s10

      Show
      db.Collection1.explain().aggregate([{ $project: { "obj.newField" : "$topLevelScalar" } }, { $project: { "obj.a" : 0 } }]); generates the plan [4] project [s14 = makeBsonObj(MakeObjSpec([obj = MakeObj([a], Open, RetInput)], [_id, obj], Closed, RetInput), null , true , s8, s13)] [3] project [s13 = getField(s12, \ "obj\" )] [3] project [s12 = makeBsonObj(MakeObjSpec([obj = MakeObj([newField = Arg(0)], Closed)], [obj], Closed), null , true , s9, s7)] [3] block_to_row blocks[s3, s4, s7, s5] row[s8, s9, s10, s11] [3] project [s7 = cellFoldValues_P(cellBlockGetFlatValuesBlock(s5), s5)] [2] ts_bucket_to_cellblock s1 pathReqs[s3 = ProjectPath(Get(_id)/Id), s4 = ProjectPath(Get(obj)/Id), s5 = ProjectPath(Get(topLevelScalar)/Id)] [1] scan s1 s2 none none none none none none lowPriority [] @\ "be9e4531-c681-4da5-b7db-8326db4ad559\" true false where makeBsonObj uses s7 instead of s10
    • QE 2024-02-05
    • 155

      In a $project that supports processing block values, we first associate a slot id to the projected path, then, if we have to transition to scalar processing, we allocate a new slot to hold the sequence of scalar values coming out of that block thanks to the TsBlockToRow stage. However, the slot id holding the block value is still kept in the "nodes" variable that is used when assembling the result object, ending up at runtime with a block value passed to a call to makeBsonObj.

            Assignee:
            alberto.massari@mongodb.com Alberto Massari
            Reporter:
            alberto.massari@mongodb.com Alberto Massari
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: