[SERVER-65669] $lookup/$project causes SIGABRT on 6.0.0-alpha Created: 14/Apr/22  Updated: 27/Oct/23  Resolved: 18/Apr/22

Status: Closed
Project: Core Server
Component/s: Query Execution
Affects Version/s: None
Fix Version/s: 6.0.0-rc0

Type: Bug Priority: Blocker - P1
Reporter: James Kovacs Assignee: Yoon Soo Kim
Resolution: Gone away Votes: 0
Labels: sbe
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File mongod.log.gz    
Operating System: ALL
Sprint: QE 2022-05-02
Participants:

 Description   

Running a $lookup/$project aggregation causes an invariant failure in sbe_stage_builder.h on 6.0.0-alpha:

{"t":{"$date":"2022-04-14T12:07:04.326-06:00"},"s":"F",  "c":"ASSERT",   "id":23079,   "ctx":"conn1","msg":"Invariant failure","attr":{"expr":"it != _slots.end()","file":"src/mongo/db/query/sbe_stage_builder.h","line":261}}

This failure occurs on Linux, OSX, and Windows and is completely reproducible. This $lookup/$project query has been part of the .NET/C# driver test suite for many years and runs successfully on earlier server versions.



 Comments   
Comment by Yoon Soo Kim [ 18/Apr/22 ]

According to the RCA above, closing this "Gone Away".

Comment by Yoon Soo Kim [ 18/Apr/22 ]

Adding the following code to SlotBasedStageBuilder::SlotBasedStageBuilder() on the commit that 6.0.0-alpha-1179-gdc27194 was built on fixes the issue.

    const auto [lookupNode, lookupCount] = getFirstNodeByType(solution.root(), STAGE_EQ_LOOKUP);
    if (lookupCount) {
        _shouldProduceRecordIdSlot = false;
    }

The above fix is extracted from Nikita's patch: https://github.com/mongodb/mongo/commit/3780d57e1e378b55a887a43115c8d303e8962a6b

It looks like that the following commit is the root cause.

https://github.com/mongodb/mongo/commit/f554b4b4071ffcf177e526b1bc64632e8220e46d

It didn't account for the $lookup pushdown feature since the feature was not enabled by default at the moment.

And the following commit exposed the issue in a non-feature-flag build variant.

https://github.com/mongodb/mongo/commit/86efc4be5f8921af9e8b89ef4219b089ef0c67cd

Fortunately, before we branched out v6.0, nikita.lapkov@mongodb.com's patch has made it to the master branch.

So, now we don't have this issue on both the master and v6.0 and this issue must not be a blocker for v6.0.

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