[SERVER-83502] Project error when referencing $$ROOT on v7.2.0-rc1 Created: 21/Nov/23  Updated: 01/Dec/23  Resolved: 01/Dec/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc2

Type: Bug Priority: Major - P3
Reporter: Ann Wang Assignee: Drew Paroski
Resolution: Fixed Votes: 0
Labels: adf, bkp
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Connect via mongosh running on MongoDB 7.2.0-rc1 and run the failing queries from the description.

Sprint: QE 2023-12-11
Participants:

 Description   

Seeing the error "Cannot require both kResult and MakeResultInfo" when attempting to run queries with a second project stage referencing a newly created field in a stage ($project/$addFields). Related to ticket SERVER-81466 that changes project generation.

Examples of queries that failed with this error (v7.2.0-rc1):

Note: Running on v6.0.11 works as expected with no error.

db.atlascoll.aggregate({ "$project": { "newfield1": "$$ROOT" } }, { "$project": { "newfield2": "$newfield1" } })
 
db.atlascoll.aggregate({ "$addFields": { "newfield1": "$$ROOT" } }, { "$project": { "newfield2": "$newfield1" } })

Examples of queries that completed successfully:

db.atlascoll.aggregate({ "$project": { "newfield1": "$$ROOT" } }, { "$match": { "newfield1.a": 2 } }) - running a single $project followed by match
db.atlascoll.aggregate({ "$project": { "newfield1": "$$ROOT" } }, { "$project": { "newfield2": "$$ROOT" } }) - running two projects with the second one also referencing $$ROOT
db.atlascoll.aggregate({ "$project": { "newfield1": "$$NOW" } }, { "$project": { "newfield2": "$newfield1" } }) - running the same query but using the system var $$NOW instead
db.atlascoll.aggregate({ "$addFields": { "newfield1": "$$ROOT" } }, { "$addFields": { "newfield2": "$newfield1" } }) - using addFields instead of project

Some additional info in the slack thread here.


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