[SERVER-85755] Block-enabled projection transitioning to scalar processing doesn't clean up the state Created: 25/Jan/24  Updated: 07/Feb/24  Resolved: 31/Jan/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 8.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Alberto Massari Assignee: Alberto Massari
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-86339 Disable vectorization of $project in 7.3 Backlog
Assigned Teams:
Query Execution
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

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

Sprint: QE 2024-02-05
Participants:
Linked BF Score: 155

 Description   

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.



 Comments   
Comment by Githook User [ 31/Jan/24 ]

Author:

{'name': 'Alberto Massari', 'email': 'alberto.massari@mongodb.com', 'username': 'albymassari'}

Message: SERVER-85755 Avoid that a ProjectStage references its own slots (#18524)

GitOrigin-RevId: 38ff16ea3179906f0ddeef0f2f02542c2a7d6c2e
Branch: master
https://github.com/mongodb/mongo/commit/a01e4de7134db0b6866373078f1cd151612df58c

Comment by Githook User [ 29/Jan/24 ]

Author:

{'name': 'Alberto Massari', 'email': 'alberto.massari@mongodb.com', 'username': 'albymassari'}

Message: SERVER-85755 Ensure that vectorized slot are not visible to scalar stages (#18436)

GitOrigin-RevId: b48a7e749f91b1a7860da96da2315fdc10a96736
Branch: master
https://github.com/mongodb/mongo/commit/9e98fbc95d4de072c46a8440c39821e8d0cb95ec

Generated at Thu Feb 08 06:58:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.